some mods to the plugin API
This commit is contained in:
parent
8cdb9a316f
commit
abf3337888
@ -35,6 +35,15 @@ void cmSetClientData(void *info, void *cd)
|
|||||||
((cmLoadedCommandInfo *)info)->ClientData = cd;
|
((cmLoadedCommandInfo *)info)->ClientData = cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmSetError(void *info, const char *err)
|
||||||
|
{
|
||||||
|
if (((cmLoadedCommandInfo *)info)->Error)
|
||||||
|
{
|
||||||
|
free(((cmLoadedCommandInfo *)info)->Error);
|
||||||
|
}
|
||||||
|
((cmLoadedCommandInfo *)info)->Error = strdup(err);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int cmGetCacheMajorVersion(void *arg)
|
unsigned int cmGetCacheMajorVersion(void *arg)
|
||||||
{
|
{
|
||||||
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
||||||
@ -464,6 +473,7 @@ cmCAPI cmStaticCAPI =
|
|||||||
cmGetTotalArgumentSize,
|
cmGetTotalArgumentSize,
|
||||||
cmFreeArguments,
|
cmFreeArguments,
|
||||||
cmSetClientData,
|
cmSetClientData,
|
||||||
|
cmSetError,
|
||||||
cmAddCacheDefinition,
|
cmAddCacheDefinition,
|
||||||
cmAddCustomCommand,
|
cmAddCustomCommand,
|
||||||
cmAddDefineFlag,
|
cmAddDefineFlag,
|
||||||
|
@ -52,6 +52,8 @@ typedef struct
|
|||||||
information is passed from the InitialPass to FInalPass for commands
|
information is passed from the InitialPass to FInalPass for commands
|
||||||
that need a FinalPass and need information from the InitialPass */
|
that need a FinalPass and need information from the InitialPass */
|
||||||
void (*SetClientData) (void *info, void *cd);
|
void (*SetClientData) (void *info, void *cd);
|
||||||
|
/* when an error occurs, call this function to set the error string */
|
||||||
|
void (*SetError) (void *info, const char *err);
|
||||||
|
|
||||||
/*=========================================================================
|
/*=========================================================================
|
||||||
The following functions all directly map to methods in the cmMakefile
|
The following functions all directly map to methods in the cmMakefile
|
||||||
@ -188,6 +190,7 @@ Finally we define the key data structures and function prototypes
|
|||||||
CM_DOC_FUNCTION GetTerseDocumentation;
|
CM_DOC_FUNCTION GetTerseDocumentation;
|
||||||
CM_DOC_FUNCTION GetFullDocumentation;
|
CM_DOC_FUNCTION GetFullDocumentation;
|
||||||
const char *Name;
|
const char *Name;
|
||||||
|
char *Error;
|
||||||
void *ClientData;
|
void *ClientData;
|
||||||
} cmLoadedCommandInfo;
|
} cmLoadedCommandInfo;
|
||||||
|
|
||||||
|
@ -111,6 +111,12 @@ bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear the error string
|
||||||
|
if (this->info.Error)
|
||||||
|
{
|
||||||
|
free(this->info.Error);
|
||||||
|
}
|
||||||
|
|
||||||
// create argc and argv and then invoke the command
|
// create argc and argv and then invoke the command
|
||||||
int argc = static_cast<int> (args.size());
|
int argc = static_cast<int> (args.size());
|
||||||
char **argv = 0;
|
char **argv = 0;
|
||||||
@ -125,10 +131,17 @@ bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args)
|
|||||||
}
|
}
|
||||||
int result = info.InitialPass((void *)&info,(void *)this->m_Makefile,argc,argv);
|
int result = info.InitialPass((void *)&info,(void *)this->m_Makefile,argc,argv);
|
||||||
cmFreeArguments(argc,argv);
|
cmFreeArguments(argc,argv);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initial Pass must have failed so set the error string */
|
||||||
|
if (this->info.Error)
|
||||||
|
{
|
||||||
|
this->SetError(this->info.Error);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +159,10 @@ cmLoadedCommand::~cmLoadedCommand()
|
|||||||
{
|
{
|
||||||
this->info.Destructor((void *)&this->info);
|
this->info.Destructor((void *)&this->info);
|
||||||
}
|
}
|
||||||
|
if (this->info.Error)
|
||||||
|
{
|
||||||
|
free(this->info.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cmLoadCommandCommand
|
// cmLoadCommandCommand
|
||||||
@ -187,16 +204,18 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& argsIn)
|
|||||||
cmLibHandle lib = cmDynamicLoader::OpenLibrary(fullPath.c_str());
|
cmLibHandle lib = cmDynamicLoader::OpenLibrary(fullPath.c_str());
|
||||||
if(lib)
|
if(lib)
|
||||||
{
|
{
|
||||||
// Look for the symbol cmLoad, cmGetFactoryCompilerUsed,
|
// find the init function
|
||||||
// and cmGetFactoryVersion in the library
|
std::string initFuncName = args[0] + "Init";
|
||||||
CM_INIT_FUNCTION initFunction
|
CM_INIT_FUNCTION initFunction
|
||||||
= (CM_INIT_FUNCTION)
|
= (CM_INIT_FUNCTION)
|
||||||
cmDynamicLoader::GetSymbolAddress(lib, "cmInitializeCommand");
|
cmDynamicLoader::GetSymbolAddress(lib, initFuncName.c_str());
|
||||||
if ( !initFunction )
|
if ( !initFunction )
|
||||||
{
|
{
|
||||||
initFunction =
|
initFuncName = "_";
|
||||||
(CM_INIT_FUNCTION)(
|
initFuncName += args[0];
|
||||||
cmDynamicLoader::GetSymbolAddress(lib, "_cmInitializeCommand"));
|
initFuncName += "Init";
|
||||||
|
initFunction = (CM_INIT_FUNCTION)(
|
||||||
|
cmDynamicLoader::GetSymbolAddress(lib, initFuncName.c_str()));
|
||||||
}
|
}
|
||||||
// if the symbol is found call it to set the name on the
|
// if the symbol is found call it to set the name on the
|
||||||
// function blocker
|
// function blocker
|
||||||
|
Loading…
x
Reference in New Issue
Block a user