resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmCPluginAPI.h
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 /* This header file defines the API that loadable commands can use. In many
4    of these commands C++ instances of cmMakefile of cmSourceFile are passed
5    in as arguments or returned. In these cases they are passed as a void *
6    argument. In the function prototypes mf is used to represent a makefile
7    and sf is used to represent a source file. The functions are grouped
8    loosely into four groups 1) Utility 2) cmMakefile 3) cmSourceFile 4)
9    cmSystemTools. Within each grouping functions are listed alphabetically */
10 /*=========================================================================*/
11 #ifndef cmCPluginAPI_h
12 #define cmCPluginAPI_h
13
14 #define CMAKE_VERSION_MAJOR 2
15 #define CMAKE_VERSION_MINOR 5
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 #ifdef __WATCOMC__
22 #  define CCONV __cdecl
23 #else
24 #  define CCONV
25 #endif
26 /*=========================================================================
27 this is the structure of function entry points that a plugin may call. This
28 structure must be kept in sync with the static decaled at the bottom of
29 cmCPLuginAPI.cxx
30 =========================================================================*/
31 /* NOLINTNEXTLINE(modernize-use-using) */
32 typedef struct
33 {
34   /*=========================================================================
35   Here we define the set of functions that a plugin may call. The first goup
36   of functions are utility functions that are specific to the plugin API
37   =========================================================================*/
38   /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
39      information is passed from the InitialPass to FinalPass for commands
40      that need a FinalPass and need information from the InitialPass */
41   void*(CCONV* GetClientData)(void* info);
42   /* return the summed size in characters of all the arguments */
43   int(CCONV* GetTotalArgumentSize)(int argc, char** argv);
44   /* free all the memory associated with an argc, argv pair */
45   void(CCONV* FreeArguments)(int argc, char** argv);
46   /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
47      information is passed from the InitialPass to FinalPass for commands
48      that need a FinalPass and need information from the InitialPass */
49   void(CCONV* SetClientData)(void* info, void* cd);
50   /* when an error occurs, call this function to set the error string */
51   void(CCONV* SetError)(void* info, const char* err);
52
53   /*=========================================================================
54   The following functions all directly map to methods in the cmMakefile
55   class. See cmMakefile.h for descriptions of what each method does. All of
56   these methods take the void * makefile pointer as their first argument.
57   =========================================================================*/
58   void(CCONV* AddCacheDefinition)(void* mf, const char* name,
59                                   const char* value, const char* doc,
60                                   int cachetype);
61   void(CCONV* AddCustomCommand)(void* mf, const char* source,
62                                 const char* command, int numArgs,
63                                 const char** args, int numDepends,
64                                 const char** depends, int numOutputs,
65                                 const char** outputs, const char* target);
66   void(CCONV* AddDefineFlag)(void* mf, const char* definition);
67   void(CCONV* AddDefinition)(void* mf, const char* name, const char* value);
68   void(CCONV* AddExecutable)(void* mf, const char* exename, int numSrcs,
69                              const char** srcs, int win32);
70   void(CCONV* AddLibrary)(void* mf, const char* libname, int shared,
71                           int numSrcs, const char** srcs);
72   void(CCONV* AddLinkDirectoryForTarget)(void* mf, const char* tgt,
73                                          const char* d);
74   void(CCONV* AddLinkLibraryForTarget)(void* mf, const char* tgt,
75                                        const char* libname, int libtype);
76   void(CCONV* AddUtilityCommand)(void* mf, const char* utilityName,
77                                  const char* command, const char* arguments,
78                                  int all, int numDepends, const char** depends,
79                                  int numOutputs, const char** outputs);
80   int(CCONV* CommandExists)(void* mf, const char* name);
81   int(CCONV* ExecuteCommand)(void* mf, const char* name, int numArgs,
82                              const char** args);
83   void(CCONV* ExpandSourceListArguments)(void* mf, int argc, const char** argv,
84                                          int* resArgc, char*** resArgv,
85                                          unsigned int startArgumentIndex);
86   char*(CCONV* ExpandVariablesInString)(void* mf, const char* source,
87                                         int escapeQuotes, int atOnly);
88   unsigned int(CCONV* GetCacheMajorVersion)(void* mf);
89   unsigned int(CCONV* GetCacheMinorVersion)(void* mf);
90   const char*(CCONV* GetCurrentDirectory)(void* mf);
91   const char*(CCONV* GetCurrentOutputDirectory)(void* mf);
92   const char*(CCONV* GetDefinition)(void* mf, const char* def);
93   const char*(CCONV* GetHomeDirectory)(void* mf);
94   const char*(CCONV* GetHomeOutputDirectory)(void* mf);
95   unsigned int(CCONV* GetMajorVersion)(void* mf);
96   unsigned int(CCONV* GetMinorVersion)(void* mf);
97   const char*(CCONV* GetProjectName)(void* mf);
98   const char*(CCONV* GetStartDirectory)(void* mf);
99   const char*(CCONV* GetStartOutputDirectory)(void* mf);
100   int(CCONV* IsOn)(void* mf, const char* name);
101
102   /*=========================================================================
103   The following functions are designed to operate or manipulate
104   cmSourceFiles. Please see cmSourceFile.h for additional information on many
105   of these methods. Some of these methods are in cmMakefile.h.
106   =========================================================================*/
107   void*(CCONV* AddSource)(void* mf, void* sf);
108   void*(CCONV* CreateSourceFile)();
109   void(CCONV* DestroySourceFile)(void* sf);
110   void*(CCONV* GetSource)(void* mf, const char* sourceName);
111   void(CCONV* SourceFileAddDepend)(void* sf, const char* depend);
112   const char*(CCONV* SourceFileGetProperty)(void* sf, const char* prop);
113   int(CCONV* SourceFileGetPropertyAsBool)(void* sf, const char* prop);
114   const char*(CCONV* SourceFileGetSourceName)(void* sf);
115   const char*(CCONV* SourceFileGetFullPath)(void* sf);
116   void(CCONV* SourceFileSetName)(void* sf, const char* name, const char* dir,
117                                  int numSourceExtensions,
118                                  const char** sourceExtensions,
119                                  int numHeaderExtensions,
120                                  const char** headerExtensions);
121   void(CCONV* SourceFileSetName2)(void* sf, const char* name, const char* dir,
122                                   const char* ext, int headerFileOnly);
123   void(CCONV* SourceFileSetProperty)(void* sf, const char* prop,
124                                      const char* value);
125
126   /*=========================================================================
127   The following methods are from cmSystemTools.h see that file for specific
128   documentation on each method.
129   =========================================================================*/
130   char*(CCONV* Capitalized)(const char*);
131   void(CCONV* CopyFileIfDifferent)(const char* f1, const char* f2);
132   char*(CCONV* GetFilenameWithoutExtension)(const char*);
133   char*(CCONV* GetFilenamePath)(const char*);
134   void(CCONV* RemoveFile)(const char* f1);
135   void(CCONV* Free)(void*);
136
137   /*=========================================================================
138     The following are new functions added after 1.6
139   =========================================================================*/
140   void(CCONV* AddCustomCommandToOutput)(void* mf, const char* output,
141                                         const char* command, int numArgs,
142                                         const char** args,
143                                         const char* main_dependency,
144                                         int numDepends, const char** depends);
145   void(CCONV* AddCustomCommandToTarget)(void* mf, const char* target,
146                                         const char* command, int numArgs,
147                                         const char** args, int commandType);
148
149   /* display status information */
150   void(CCONV* DisplaySatus)(void* info, const char* message);
151
152   /* new functions added after 2.4 */
153   void*(CCONV* CreateNewSourceFile)(void* mf);
154   void(CCONV* DefineSourceFileProperty)(void* mf, const char* name,
155                                         const char* briefDocs,
156                                         const char* longDocs, int chained);
157
158   /* this is the end of the C function stub API structure */
159 } cmCAPI;
160
161 /*=========================================================================
162 CM_PLUGIN_EXPORT should be used by plugins
163 =========================================================================*/
164 #ifdef _WIN32
165 #  define CM_PLUGIN_EXPORT __declspec(dllexport)
166 #else
167 #  define CM_PLUGIN_EXPORT
168 #endif
169
170 /*=========================================================================
171 define the different types of cache entries, see cmCacheManager.h for more
172 information
173 =========================================================================*/
174 #define CM_CACHE_BOOL 0
175 #define CM_CACHE_PATH 1
176 #define CM_CACHE_FILEPATH 2
177 #define CM_CACHE_STRING 3
178 #define CM_CACHE_INTERNAL 4
179 #define CM_CACHE_STATIC 5
180
181 /*=========================================================================
182 define the different types of compiles a library may be
183 =========================================================================*/
184 #define CM_LIBRARY_GENERAL 0
185 #define CM_LIBRARY_DEBUG 1
186 #define CM_LIBRARY_OPTIMIZED 2
187
188 /*=========================================================================
189 define the different types of custom commands for a target
190 =========================================================================*/
191 #define CM_PRE_BUILD 0
192 #define CM_PRE_LINK 1
193 #define CM_POST_BUILD 2
194
195 /*=========================================================================
196 Finally we define the key data structures and function prototypes
197 =========================================================================*/
198
199 /* NOLINTNEXTLINE(modernize-use-using) */
200 typedef const char*(CCONV* CM_DOC_FUNCTION)();
201
202 /* NOLINTNEXTLINE(modernize-use-using) */
203 typedef int(CCONV* CM_INITIAL_PASS_FUNCTION)(void* info, void* mf, int argc,
204                                              char* []);
205
206 /* NOLINTNEXTLINE(modernize-use-using) */
207 typedef void(CCONV* CM_FINAL_PASS_FUNCTION)(void* info, void* mf);
208
209 /* NOLINTNEXTLINE(modernize-use-using) */
210 typedef void(CCONV* CM_DESTRUCTOR_FUNCTION)(void* info);
211
212 /* NOLINTNEXTLINE(modernize-use-using) */
213 typedef struct
214 {
215   unsigned long reserved1; /* Reserved for future use.  DO NOT USE.  */
216   unsigned long reserved2; /* Reserved for future use.  DO NOT USE.  */
217   cmCAPI* CAPI;
218   int m_Inherited; /* this ivar is no longer used in CMake 2.2 or later */
219   CM_INITIAL_PASS_FUNCTION InitialPass;
220   CM_FINAL_PASS_FUNCTION FinalPass;
221   CM_DESTRUCTOR_FUNCTION Destructor;
222   CM_DOC_FUNCTION GetTerseDocumentation;
223   CM_DOC_FUNCTION GetFullDocumentation;
224   const char* Name;
225   char* Error;
226   void* ClientData;
227 } cmLoadedCommandInfo;
228
229 /* NOLINTNEXTLINE(modernize-use-using) */
230 typedef void(CCONV* CM_INIT_FUNCTION)(cmLoadedCommandInfo*);
231
232 #ifdef __cplusplus
233 }
234 #endif
235
236 #endif