CXCompilationDatabase.odin (5361B)
1 /*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\ 2 |* *| 3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 4 |* Exceptions. *| 5 |* See https://llvm.org/LICENSE.txt for license information. *| 6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7 |* *| 8 |*===----------------------------------------------------------------------===*| 9 |* *| 10 |* This header provides a public interface to use CompilationDatabase without *| 11 |* the full Clang C++ API. *| 12 |* *| 13 \*===----------------------------------------------------------------------===*/ 14 package libclang 15 16 import "core:c" 17 18 _ :: c 19 20 when ODIN_OS == .Windows { 21 @(extra_linker_flags="/NODEFAULTLIB:libcmt") 22 foreign import lib { 23 "system:ntdll.lib", 24 "system:ucrt.lib", 25 "system:msvcrt.lib", 26 "system:legacy_stdio_definitions.lib", 27 "system:kernel32.lib", 28 "system:user32.lib", 29 "system:advapi32.lib", 30 "system:shell32.lib", 31 "system:ole32.lib", 32 "system:oleaut32.lib", 33 "system:uuid.lib", 34 "system:ws2_32.lib", 35 "system:version.lib", 36 "system:oldnames.lib", 37 "libclang.lib", 38 } 39 } else { 40 foreign import lib "system:clang" 41 } 42 43 // LLVM_CLANG_C_CXCOMPILATIONDATABASE_H :: 44 45 /** 46 * A compilation database holds all information used to compile files in a 47 * project. For each file in the database, it can be queried for the working 48 * directory or the command line used for the compiler invocation. 49 * 50 * Must be freed by \c clang_CompilationDatabase_dispose 51 */ 52 Compilation_Database :: rawptr 53 54 /** 55 * Contains the results of a search in the compilation database 56 * 57 * When searching for the compile command for a file, the compilation db can 58 * return several commands, as the file may have been compiled with 59 * different options in different places of the project. This choice of compile 60 * commands is wrapped in this opaque data structure. It must be freed by 61 * \c clang_CompileCommands_dispose. 62 */ 63 Compile_Commands :: rawptr 64 65 /** 66 * Represents the command line invocation to compile a specific file. 67 */ 68 Compile_Command :: rawptr 69 70 /** 71 * Error codes for Compilation Database 72 */ 73 Compilation_Database_Error :: enum c.int { 74 /* 75 * No error occurred 76 */ 77 NoError, 78 79 /* 80 * Database can not be loaded 81 */ 82 CanNotLoadDatabase, 83 } 84 85 @(default_calling_convention="c", link_prefix="clang_") 86 foreign lib { 87 /** 88 * Creates a compilation database from the database found in directory 89 * buildDir. For example, CMake can output a compile_commands.json which can 90 * be used to build the database. 91 * 92 * It must be freed by \c clang_CompilationDatabase_dispose. 93 */ 94 CompilationDatabase_fromDirectory :: proc(BuildDir: cstring, ErrorCode: ^Compilation_Database_Error) -> Compilation_Database --- 95 96 /** 97 * Free the given compilation database 98 */ 99 CompilationDatabase_dispose :: proc(_: Compilation_Database) --- 100 101 /** 102 * Find the compile commands used for a file. The compile commands 103 * must be freed by \c clang_CompileCommands_dispose. 104 */ 105 CompilationDatabase_getCompileCommands :: proc(_: Compilation_Database, CompleteFileName: cstring) -> Compile_Commands --- 106 107 /** 108 * Get all the compile commands in the given compilation database. 109 */ 110 CompilationDatabase_getAllCompileCommands :: proc(_: Compilation_Database) -> Compile_Commands --- 111 112 /** 113 * Free the given CompileCommands 114 */ 115 CompileCommands_dispose :: proc(_: Compile_Commands) --- 116 117 /** 118 * Get the number of CompileCommand we have for a file 119 */ 120 CompileCommands_getSize :: proc(_: Compile_Commands) -> c.uint --- 121 122 /** 123 * Get the I'th CompileCommand for a file 124 * 125 * Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands) 126 */ 127 CompileCommands_getCommand :: proc(_: Compile_Commands, I: c.uint) -> Compile_Command --- 128 129 /** 130 * Get the working directory where the CompileCommand was executed from 131 */ 132 CompileCommand_getDirectory :: proc(_: Compile_Command) -> String --- 133 134 /** 135 * Get the filename associated with the CompileCommand. 136 */ 137 CompileCommand_getFilename :: proc(_: Compile_Command) -> String --- 138 139 /** 140 * Get the number of arguments in the compiler invocation. 141 * 142 */ 143 CompileCommand_getNumArgs :: proc(_: Compile_Command) -> c.uint --- 144 145 /** 146 * Get the I'th argument value in the compiler invocations 147 * 148 * Invariant : 149 * - argument 0 is the compiler executable 150 */ 151 CompileCommand_getArg :: proc(_: Compile_Command, I: c.uint) -> String --- 152 153 /** 154 * Get the number of source mappings for the compiler invocation. 155 */ 156 CompileCommand_getNumMappedSources :: proc(_: Compile_Command) -> c.uint --- 157 158 /** 159 * Get the I'th mapped source path for the compiler invocation. 160 */ 161 CompileCommand_getMappedSourcePath :: proc(_: Compile_Command, I: c.uint) -> String --- 162 163 /** 164 * Get the I'th mapped source content for the compiler invocation. 165 */ 166 CompileCommand_getMappedSourceContent :: proc(_: Compile_Command, I: c.uint) -> String --- 167 }