1 module clang.c.CXCompilationDatabase; 2 3 public import clang.c.CXString; 4 5 extern (C): 6 7 /** \defgroup COMPILATIONDB CompilationDatabase functions 8 * \ingroup CINDEX 9 * 10 * @{ 11 */ 12 13 /** 14 * A compilation database holds all information used to compile files in a 15 * project. For each file in the database, it can be queried for the working 16 * directory or the command line used for the compiler invocation. 17 * 18 * Must be freed by \c clang_CompilationDatabase_dispose 19 */ 20 alias CXCompilationDatabase = void*; 21 22 /** 23 * \brief Contains the results of a search in the compilation database 24 * 25 * When searching for the compile command for a file, the compilation db can 26 * return several commands, as the file may have been compiled with 27 * different options in different places of the project. This choice of compile 28 * commands is wrapped in this opaque data structure. It must be freed by 29 * \c clang_CompileCommands_dispose. 30 */ 31 alias CXCompileCommands = void*; 32 33 /** 34 * \brief Represents the command line invocation to compile a specific file. 35 */ 36 alias CXCompileCommand = void*; 37 38 /** 39 * \brief Error codes for Compilation Database 40 */ 41 enum CXCompilationDatabase_Error 42 { 43 /* 44 * \brief No error occurred 45 */ 46 noError = 0, 47 48 /* 49 * \brief Database can not be loaded 50 */ 51 canNotLoadDatabase = 1 52 } 53 54 /** 55 * \brief Creates a compilation database from the database found in directory 56 * buildDir. For example, CMake can output a compile_commands.json which can 57 * be used to build the database. 58 * 59 * It must be freed by \c clang_CompilationDatabase_dispose. 60 */ 61 CXCompilationDatabase clang_CompilationDatabase_fromDirectory( 62 const(char)* BuildDir, 63 CXCompilationDatabase_Error* ErrorCode); 64 65 /** 66 * \brief Free the given compilation database 67 */ 68 void clang_CompilationDatabase_dispose(CXCompilationDatabase); 69 70 /** 71 * \brief Find the compile commands used for a file. The compile commands 72 * must be freed by \c clang_CompileCommands_dispose. 73 */ 74 CXCompileCommands clang_CompilationDatabase_getCompileCommands( 75 CXCompilationDatabase, 76 const(char)* CompleteFileName); 77 78 /** 79 * \brief Get all the compile commands in the given compilation database. 80 */ 81 CXCompileCommands clang_CompilationDatabase_getAllCompileCommands( 82 CXCompilationDatabase); 83 84 /** 85 * \brief Free the given CompileCommands 86 */ 87 void clang_CompileCommands_dispose(CXCompileCommands); 88 89 /** 90 * \brief Get the number of CompileCommand we have for a file 91 */ 92 uint clang_CompileCommands_getSize(CXCompileCommands); 93 94 /** 95 * \brief Get the I'th CompileCommand for a file 96 * 97 * Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands) 98 */ 99 CXCompileCommand clang_CompileCommands_getCommand(CXCompileCommands, uint I); 100 101 /** 102 * \brief Get the working directory where the CompileCommand was executed from 103 */ 104 CXString clang_CompileCommand_getDirectory(CXCompileCommand); 105 106 /** 107 * \brief Get the filename associated with the CompileCommand. 108 */ 109 CXString clang_CompileCommand_getFilename(CXCompileCommand); 110 111 /** 112 * \brief Get the number of arguments in the compiler invocation. 113 * 114 */ 115 uint clang_CompileCommand_getNumArgs(CXCompileCommand); 116 117 /** 118 * \brief Get the I'th argument value in the compiler invocations 119 * 120 * Invariant : 121 * - argument 0 is the compiler executable 122 */ 123 CXString clang_CompileCommand_getArg(CXCompileCommand, uint I); 124 125 /** 126 * \brief Get the number of source mappings for the compiler invocation. 127 */ 128 uint clang_CompileCommand_getNumMappedSources(CXCompileCommand); 129 130 /** 131 * \brief Get the I'th mapped source path for the compiler invocation. 132 */ 133 CXString clang_CompileCommand_getMappedSourcePath(CXCompileCommand, uint I); 134 135 /** 136 * \brief Get the I'th mapped source content for the compiler invocation. 137 */ 138 CXString clang_CompileCommand_getMappedSourceContent(CXCompileCommand, uint I); 139 140 /** 141 * @} 142 */