cmCPluginAPI.h 11 KB

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