cmCPluginAPI.h 9.6 KB

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