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