cmCPluginAPI.h 11 KB

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