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