blob: 8f26a8611719fd0f5b1ba02edf4c06e6dd609645 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001/*==-- clang-c/BuildSystem.h - Utilities for use by build systems -*- C -*-===*\
2|* *|
Andrew Walbran16937d02019-10-22 13:54:20 +01003|* 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 *|
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01007|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header provides various utilities for use by build systems. *|
11|* *|
12\*===----------------------------------------------------------------------===*/
13
14#ifndef LLVM_CLANG_C_BUILDSYSTEM_H
15#define LLVM_CLANG_C_BUILDSYSTEM_H
16
17#include "clang-c/Platform.h"
18#include "clang-c/CXErrorCode.h"
19#include "clang-c/CXString.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/**
26 * \defgroup BUILD_SYSTEM Build system utilities
27 * @{
28 */
29
30/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010031 * Return the timestamp for use with Clang's
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010032 * \c -fbuild-session-timestamp= option.
33 */
34CINDEX_LINKAGE unsigned long long clang_getBuildSessionTimestamp(void);
35
36/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010037 * Object encapsulating information about overlaying virtual
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010038 * file/directories over the real file system.
39 */
40typedef struct CXVirtualFileOverlayImpl *CXVirtualFileOverlay;
41
42/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010043 * Create a \c CXVirtualFileOverlay object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010044 * Must be disposed with \c clang_VirtualFileOverlay_dispose().
45 *
46 * \param options is reserved, always pass 0.
47 */
48CINDEX_LINKAGE CXVirtualFileOverlay
49clang_VirtualFileOverlay_create(unsigned options);
50
51/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010052 * Map an absolute virtual file path to an absolute real one.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010053 * The virtual path must be canonicalized (not contain "."/"..").
54 * \returns 0 for success, non-zero to indicate an error.
55 */
56CINDEX_LINKAGE enum CXErrorCode
57clang_VirtualFileOverlay_addFileMapping(CXVirtualFileOverlay,
58 const char *virtualPath,
59 const char *realPath);
60
61/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010062 * Set the case sensitivity for the \c CXVirtualFileOverlay object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010063 * The \c CXVirtualFileOverlay object is case-sensitive by default, this
64 * option can be used to override the default.
65 * \returns 0 for success, non-zero to indicate an error.
66 */
67CINDEX_LINKAGE enum CXErrorCode
68clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay,
Andrew Scullcdfcccc2018-10-05 20:58:37 +010069 int caseSensitive);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010070
71/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010072 * Write out the \c CXVirtualFileOverlay object to a char buffer.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010073 *
74 * \param options is reserved, always pass 0.
75 * \param out_buffer_ptr pointer to receive the buffer pointer, which should be
76 * disposed using \c clang_free().
77 * \param out_buffer_size pointer to receive the buffer size.
78 * \returns 0 for success, non-zero to indicate an error.
79 */
80CINDEX_LINKAGE enum CXErrorCode
81clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay, unsigned options,
82 char **out_buffer_ptr,
83 unsigned *out_buffer_size);
84
85/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010086 * free memory allocated by libclang, such as the buffer returned by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010087 * \c CXVirtualFileOverlay() or \c clang_ModuleMapDescriptor_writeToBuffer().
88 *
89 * \param buffer memory pointer to free.
90 */
91CINDEX_LINKAGE void clang_free(void *buffer);
92
93/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010094 * Dispose a \c CXVirtualFileOverlay object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010095 */
96CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay);
97
98/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010099 * Object encapsulating information about a module.map file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100100 */
101typedef struct CXModuleMapDescriptorImpl *CXModuleMapDescriptor;
102
103/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100104 * Create a \c CXModuleMapDescriptor object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100105 * Must be disposed with \c clang_ModuleMapDescriptor_dispose().
106 *
107 * \param options is reserved, always pass 0.
108 */
109CINDEX_LINKAGE CXModuleMapDescriptor
110clang_ModuleMapDescriptor_create(unsigned options);
111
112/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100113 * Sets the framework module name that the module.map describes.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100114 * \returns 0 for success, non-zero to indicate an error.
115 */
116CINDEX_LINKAGE enum CXErrorCode
117clang_ModuleMapDescriptor_setFrameworkModuleName(CXModuleMapDescriptor,
118 const char *name);
119
120/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100121 * Sets the umbrealla header name that the module.map describes.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100122 * \returns 0 for success, non-zero to indicate an error.
123 */
124CINDEX_LINKAGE enum CXErrorCode
125clang_ModuleMapDescriptor_setUmbrellaHeader(CXModuleMapDescriptor,
126 const char *name);
127
128/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100129 * Write out the \c CXModuleMapDescriptor object to a char buffer.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100130 *
131 * \param options is reserved, always pass 0.
132 * \param out_buffer_ptr pointer to receive the buffer pointer, which should be
133 * disposed using \c clang_free().
134 * \param out_buffer_size pointer to receive the buffer size.
135 * \returns 0 for success, non-zero to indicate an error.
136 */
137CINDEX_LINKAGE enum CXErrorCode
138clang_ModuleMapDescriptor_writeToBuffer(CXModuleMapDescriptor, unsigned options,
139 char **out_buffer_ptr,
140 unsigned *out_buffer_size);
141
142/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100143 * Dispose a \c CXModuleMapDescriptor object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100144 */
145CINDEX_LINKAGE void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor);
146
147/**
148 * @}
149 */
150
151#ifdef __cplusplus
152}
153#endif
154
155#endif /* CLANG_C_BUILD_SYSTEM_H */
156