added for each command
This commit is contained in:
parent
f783252c62
commit
4ab2650802
@ -19,12 +19,14 @@
|
|||||||
#include "cmConfigureGccXmlCommand.cxx"
|
#include "cmConfigureGccXmlCommand.cxx"
|
||||||
#include "cmElseCommand.cxx"
|
#include "cmElseCommand.cxx"
|
||||||
#include "cmEnableTestingCommand.cxx"
|
#include "cmEnableTestingCommand.cxx"
|
||||||
|
#include "cmEndForEachCommand.cxx"
|
||||||
#include "cmEndIfCommand.cxx"
|
#include "cmEndIfCommand.cxx"
|
||||||
#include "cmExecProgramCommand.cxx"
|
#include "cmExecProgramCommand.cxx"
|
||||||
#include "cmFindFileCommand.cxx"
|
#include "cmFindFileCommand.cxx"
|
||||||
#include "cmFindLibraryCommand.cxx"
|
#include "cmFindLibraryCommand.cxx"
|
||||||
#include "cmFindPathCommand.cxx"
|
#include "cmFindPathCommand.cxx"
|
||||||
#include "cmFindProgramCommand.cxx"
|
#include "cmFindProgramCommand.cxx"
|
||||||
|
#include "cmForEachCommand.cxx"
|
||||||
#include "cmGetFilenameComponentCommand.cxx"
|
#include "cmGetFilenameComponentCommand.cxx"
|
||||||
#include "cmIfCommand.cxx"
|
#include "cmIfCommand.cxx"
|
||||||
#include "cmIncludeCommand.cxx"
|
#include "cmIncludeCommand.cxx"
|
||||||
@ -71,12 +73,14 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
|
|||||||
commands.push_back(new cmConfigureGccXmlCommand);
|
commands.push_back(new cmConfigureGccXmlCommand);
|
||||||
commands.push_back(new cmElseCommand);
|
commands.push_back(new cmElseCommand);
|
||||||
commands.push_back(new cmEnableTestingCommand);
|
commands.push_back(new cmEnableTestingCommand);
|
||||||
|
commands.push_back(new cmEndForEachCommand);
|
||||||
commands.push_back(new cmEndIfCommand);
|
commands.push_back(new cmEndIfCommand);
|
||||||
commands.push_back(new cmExecProgramCommand);
|
commands.push_back(new cmExecProgramCommand);
|
||||||
commands.push_back(new cmFindFileCommand);
|
commands.push_back(new cmFindFileCommand);
|
||||||
commands.push_back(new cmFindLibraryCommand);
|
commands.push_back(new cmFindLibraryCommand);
|
||||||
commands.push_back(new cmFindPathCommand);
|
commands.push_back(new cmFindPathCommand);
|
||||||
commands.push_back(new cmFindProgramCommand);
|
commands.push_back(new cmFindProgramCommand);
|
||||||
|
commands.push_back(new cmForEachCommand);
|
||||||
commands.push_back(new cmGetFilenameComponentCommand);
|
commands.push_back(new cmGetFilenameComponentCommand);
|
||||||
commands.push_back(new cmIfCommand);
|
commands.push_back(new cmIfCommand);
|
||||||
commands.push_back(new cmIncludeCommand);
|
commands.push_back(new cmIncludeCommand);
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
* should a function be blocked
|
* should a function be blocked
|
||||||
*/
|
*/
|
||||||
virtual bool IsFunctionBlocked(const char *name, const std::vector<std::string> &args,
|
virtual bool IsFunctionBlocked(const char *name, const std::vector<std::string> &args,
|
||||||
const cmMakefile &mf) const = 0;
|
cmMakefile &mf) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* should this function blocker be removed, useful when one function adds a
|
* should this function blocker be removed, useful when one function adds a
|
||||||
@ -64,14 +64,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool ShouldRemove(const char *name,
|
virtual bool ShouldRemove(const char *name,
|
||||||
const std::vector<std::string> &args,
|
const std::vector<std::string> &args,
|
||||||
const cmMakefile &mf) const {return false;}
|
cmMakefile &mf) {return false;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the end of a CMakeList file is reached this method is called. It
|
* When the end of a CMakeList file is reached this method is called. It
|
||||||
* is not called on the end of an INCLUDE cmake file, just at the end of a
|
* is not called on the end of an INCLUDE cmake file, just at the end of a
|
||||||
* regular CMakeList file
|
* regular CMakeList file
|
||||||
*/
|
*/
|
||||||
virtual void ScopeEnded(const cmMakefile &mf) const {}
|
virtual void ScopeEnded(cmMakefile &mf) {}
|
||||||
|
|
||||||
virtual ~cmFunctionBlocker() {}
|
virtual ~cmFunctionBlocker() {}
|
||||||
};
|
};
|
||||||
|
@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
bool cmIfFunctionBlocker::
|
bool cmIfFunctionBlocker::
|
||||||
IsFunctionBlocked(const char *name, const std::vector<std::string> &args,
|
IsFunctionBlocked(const char *name, const std::vector<std::string> &args,
|
||||||
const cmMakefile &mf) const
|
cmMakefile &mf)
|
||||||
{
|
{
|
||||||
if (!strcmp(name,"ELSE") || !strcmp(name,"ENDIF"))
|
if (!strcmp(name,"ELSE") || !strcmp(name,"ENDIF"))
|
||||||
{
|
{
|
||||||
@ -63,13 +63,13 @@ IsFunctionBlocked(const char *name, const std::vector<std::string> &args,
|
|||||||
|
|
||||||
bool cmIfFunctionBlocker::
|
bool cmIfFunctionBlocker::
|
||||||
ShouldRemove(const char *name, const std::vector<std::string> &args,
|
ShouldRemove(const char *name, const std::vector<std::string> &args,
|
||||||
const cmMakefile &mf) const
|
cmMakefile &mf)
|
||||||
{
|
{
|
||||||
return !this->IsFunctionBlocked(name,args,mf);
|
return !this->IsFunctionBlocked(name,args,mf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmIfFunctionBlocker::
|
void cmIfFunctionBlocker::
|
||||||
ScopeEnded(const cmMakefile &mf) const
|
ScopeEnded(cmMakefile &mf)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("The end of a CMakeLists file was reached with an IF statement that was not closed properly. Within the directory: ",
|
cmSystemTools::Error("The end of a CMakeLists file was reached with an IF statement that was not closed properly. Within the directory: ",
|
||||||
mf.GetCurrentDirectory(),
|
mf.GetCurrentDirectory(),
|
||||||
|
@ -57,11 +57,11 @@ public:
|
|||||||
virtual ~cmIfFunctionBlocker() {}
|
virtual ~cmIfFunctionBlocker() {}
|
||||||
virtual bool IsFunctionBlocked(const char *name,
|
virtual bool IsFunctionBlocked(const char *name,
|
||||||
const std::vector<std::string> &args,
|
const std::vector<std::string> &args,
|
||||||
const cmMakefile &mf) const;
|
cmMakefile &mf);
|
||||||
virtual bool ShouldRemove(const char *name,
|
virtual bool ShouldRemove(const char *name,
|
||||||
const std::vector<std::string> &args,
|
const std::vector<std::string> &args,
|
||||||
const cmMakefile &mf) const;
|
cmMakefile &mf);
|
||||||
virtual void ScopeEnded(const cmMakefile &mf) const;
|
virtual void ScopeEnded(cmMakefile &mf);
|
||||||
|
|
||||||
std::string m_Define;
|
std::string m_Define;
|
||||||
bool m_Not;
|
bool m_Not;
|
||||||
|
@ -217,6 +217,52 @@ void cmMakefile::Print() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cmMakefile::ExecuteCommand(std::string &name,
|
||||||
|
std::vector<std::string> &arguments)
|
||||||
|
{
|
||||||
|
RegisteredCommandsMap::iterator pos = m_Commands.find(name);
|
||||||
|
if(pos != m_Commands.end())
|
||||||
|
{
|
||||||
|
cmCommand* rm = (*pos).second;
|
||||||
|
cmCommand* usedCommand = rm->Clone();
|
||||||
|
usedCommand->SetMakefile(this);
|
||||||
|
bool keepCommand = false;
|
||||||
|
if(usedCommand->GetEnabled())
|
||||||
|
{
|
||||||
|
// if not running in inherit mode or
|
||||||
|
// if the command is inherited then InitialPass it.
|
||||||
|
if(!m_Inheriting || usedCommand->IsInherited())
|
||||||
|
{
|
||||||
|
if(!usedCommand->InitialPass(arguments))
|
||||||
|
{
|
||||||
|
cmSystemTools::Error(usedCommand->GetName(),
|
||||||
|
": Error : \n",
|
||||||
|
usedCommand->GetError(),
|
||||||
|
m_cmCurrentDirectory.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// use the command
|
||||||
|
keepCommand = true;
|
||||||
|
m_UsedCommands.push_back(usedCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if the Cloned command was not used
|
||||||
|
// then delete it
|
||||||
|
if(!keepCommand)
|
||||||
|
{
|
||||||
|
delete usedCommand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("unknown CMake command ", name.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parse the given CMakeLists.txt file into a list of classes.
|
// Parse the given CMakeLists.txt file into a list of classes.
|
||||||
// Reads in current CMakeLists file and all parent CMakeLists files
|
// Reads in current CMakeLists file and all parent CMakeLists files
|
||||||
// executing all inherited commands in the parents
|
// executing all inherited commands in the parents
|
||||||
@ -273,7 +319,7 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external)
|
|||||||
//
|
//
|
||||||
// this might, or might not be true, irrespective if we are
|
// this might, or might not be true, irrespective if we are
|
||||||
// off looking at an external makefile.
|
// off looking at an external makefile.
|
||||||
bool inheriting = (m_cmCurrentDirectory != m_cmStartDirectory);
|
m_Inheriting = (m_cmCurrentDirectory != m_cmStartDirectory);
|
||||||
|
|
||||||
// Now read the input file
|
// Now read the input file
|
||||||
const char *filenametoread= filename;
|
const char *filenametoread= filename;
|
||||||
@ -299,45 +345,7 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external)
|
|||||||
if(cmSystemTools::ParseFunction(fin, name, arguments) &&
|
if(cmSystemTools::ParseFunction(fin, name, arguments) &&
|
||||||
!this->IsFunctionBlocked(name.c_str(),arguments))
|
!this->IsFunctionBlocked(name.c_str(),arguments))
|
||||||
{
|
{
|
||||||
RegisteredCommandsMap::iterator pos = m_Commands.find(name);
|
this->ExecuteCommand(name,arguments);
|
||||||
if(pos != m_Commands.end())
|
|
||||||
{
|
|
||||||
cmCommand* rm = (*pos).second;
|
|
||||||
cmCommand* usedCommand = rm->Clone();
|
|
||||||
usedCommand->SetMakefile(this);
|
|
||||||
bool keepCommand = false;
|
|
||||||
if(usedCommand->GetEnabled())
|
|
||||||
{
|
|
||||||
// if not running in inherit mode or
|
|
||||||
// if the command is inherited then InitialPass it.
|
|
||||||
if(!inheriting || usedCommand->IsInherited())
|
|
||||||
{
|
|
||||||
if(!usedCommand->InitialPass(arguments))
|
|
||||||
{
|
|
||||||
cmSystemTools::Error(usedCommand->GetName(),
|
|
||||||
": Error : \n",
|
|
||||||
usedCommand->GetError(),
|
|
||||||
m_cmCurrentDirectory.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// use the command
|
|
||||||
keepCommand = true;
|
|
||||||
m_UsedCommands.push_back(usedCommand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if the Cloned command was not used
|
|
||||||
// then delete it
|
|
||||||
if(!keepCommand)
|
|
||||||
{
|
|
||||||
delete usedCommand;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmSystemTools::Error("unknown CMake command ", name.c_str(), filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -923,7 +931,7 @@ cmMakefile::FindSourceGroup(const char* source,
|
|||||||
|
|
||||||
|
|
||||||
bool cmMakefile::IsFunctionBlocked(const char *name,
|
bool cmMakefile::IsFunctionBlocked(const char *name,
|
||||||
std::vector<std::string> &args) const
|
std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
// loop over all function blockers to see if any block this command
|
// loop over all function blockers to see if any block this command
|
||||||
std::set<cmFunctionBlocker *>::const_iterator pos;
|
std::set<cmFunctionBlocker *>::const_iterator pos;
|
||||||
|
@ -493,6 +493,13 @@ public:
|
|||||||
void RegisterData(const char*, cmData*);
|
void RegisterData(const char*, cmData*);
|
||||||
cmData* LookupData(const char*) const;
|
cmData* LookupData(const char*) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* execute a single CMake command
|
||||||
|
*/
|
||||||
|
void cmMakefile::ExecuteCommand(std::string &name,
|
||||||
|
std::vector<std::string> &args);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string m_Prefix;
|
std::string m_Prefix;
|
||||||
std::vector<std::string> m_AuxSourceDirectories; //
|
std::vector<std::string> m_AuxSourceDirectories; //
|
||||||
@ -531,7 +538,7 @@ protected:
|
|||||||
RegisteredCommandsMap m_Commands;
|
RegisteredCommandsMap m_Commands;
|
||||||
std::vector<cmCommand*> m_UsedCommands;
|
std::vector<cmCommand*> m_UsedCommands;
|
||||||
cmMakefileGenerator* m_MakefileGenerator;
|
cmMakefileGenerator* m_MakefileGenerator;
|
||||||
bool IsFunctionBlocked(const char *name, std::vector<std::string> &args) const;
|
bool IsFunctionBlocked(const char *name, std::vector<std::string> &args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -550,6 +557,7 @@ private:
|
|||||||
|
|
||||||
typedef std::map<std::string, cmData*> DataMap;
|
typedef std::map<std::string, cmData*> DataMap;
|
||||||
DataMap m_DataMap;
|
DataMap m_DataMap;
|
||||||
|
bool m_Inheriting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user