Try to improve source group interface
This commit is contained in:
parent
77616437d1
commit
a518fed4e3
@ -141,7 +141,7 @@ void cmMakefile::Print() const
|
|||||||
m_cmStartDirectory.c_str() << std::endl;
|
m_cmStartDirectory.c_str() << std::endl;
|
||||||
std::cout << " m_cmHomeDirectory; " <<
|
std::cout << " m_cmHomeDirectory; " <<
|
||||||
m_cmHomeDirectory.c_str() << std::endl;
|
m_cmHomeDirectory.c_str() << std::endl;
|
||||||
std::cout << " m_ProjectName; " << m_ProjectName.c_str() << std::endl;
|
std::cout << " m_ProjectName; " << m_ProjectName.c_str() << std::endl;
|
||||||
this->PrintStringVector("m_SubDirectories ", m_SubDirectories);
|
this->PrintStringVector("m_SubDirectories ", m_SubDirectories);
|
||||||
this->PrintStringVector("m_IncludeDirectories;", m_IncludeDirectories);
|
this->PrintStringVector("m_IncludeDirectories;", m_IncludeDirectories);
|
||||||
this->PrintStringVector("m_LinkDirectories", m_LinkDirectories);
|
this->PrintStringVector("m_LinkDirectories", m_LinkDirectories);
|
||||||
@ -193,12 +193,12 @@ void cmMakefile::ExecuteCommand(std::string const &name,
|
|||||||
}
|
}
|
||||||
if(!usedCommand->InitialPass(expandedArguments))
|
if(!usedCommand->InitialPass(expandedArguments))
|
||||||
{
|
{
|
||||||
std::string error;
|
std::string error;
|
||||||
error = usedCommand->GetName();
|
error = usedCommand->GetName();
|
||||||
error += ": Error : \n";
|
error += ": Error : \n";
|
||||||
error += usedCommand->GetError();
|
error += usedCommand->GetError();
|
||||||
error += " from CMakeLists.txt file in directory: ";
|
error += " from CMakeLists.txt file in directory: ";
|
||||||
error += m_cmCurrentDirectory;
|
error += m_cmCurrentDirectory;
|
||||||
cmSystemTools::Error(error.c_str());
|
cmSystemTools::Error(error.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -271,27 +271,27 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external)
|
|||||||
// Home directory? if so recurse and read in that List file
|
// Home directory? if so recurse and read in that List file
|
||||||
std::string parentList = this->GetParentListFileName(filename);
|
std::string parentList = this->GetParentListFileName(filename);
|
||||||
if (parentList != "")
|
if (parentList != "")
|
||||||
{
|
{
|
||||||
std::string srcdir = m_cmCurrentDirectory;
|
std::string srcdir = m_cmCurrentDirectory;
|
||||||
std::string bindir = m_CurrentOutputDirectory;
|
std::string bindir = m_CurrentOutputDirectory;
|
||||||
|
|
||||||
std::string::size_type pos = parentList.rfind('/');
|
std::string::size_type pos = parentList.rfind('/');
|
||||||
|
|
||||||
m_cmCurrentDirectory = parentList.substr(0, pos);
|
m_cmCurrentDirectory = parentList.substr(0, pos);
|
||||||
m_CurrentOutputDirectory = m_HomeOutputDirectory + parentList.substr(m_cmHomeDirectory.size(), pos - m_cmHomeDirectory.size());
|
m_CurrentOutputDirectory = m_HomeOutputDirectory + parentList.substr(m_cmHomeDirectory.size(), pos - m_cmHomeDirectory.size());
|
||||||
|
|
||||||
// if not found, oops
|
// if not found, oops
|
||||||
if(pos == std::string::npos)
|
if(pos == std::string::npos)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("Trailing slash not found");
|
cmSystemTools::Error("Trailing slash not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
this->ReadListFile(parentList.c_str());
|
this->ReadListFile(parentList.c_str());
|
||||||
|
|
||||||
// restore the current directory
|
// restore the current directory
|
||||||
m_cmCurrentDirectory = srcdir;
|
m_cmCurrentDirectory = srcdir;
|
||||||
m_CurrentOutputDirectory = bindir;
|
m_CurrentOutputDirectory = bindir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// are we at the start CMakeLists file or are we processing a parent
|
// are we at the start CMakeLists file or are we processing a parent
|
||||||
@ -452,7 +452,7 @@ void cmMakefile::AddDefineFlag(const char* flag)
|
|||||||
void cmMakefile::AddLinkLibrary(const char* lib, cmTarget::LinkLibraryType llt)
|
void cmMakefile::AddLinkLibrary(const char* lib, cmTarget::LinkLibraryType llt)
|
||||||
{
|
{
|
||||||
m_LinkLibraries.push_back(
|
m_LinkLibraries.push_back(
|
||||||
std::pair<std::string, cmTarget::LinkLibraryType>(lib,llt));
|
std::pair<std::string, cmTarget::LinkLibraryType>(lib,llt));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefile::AddLinkLibraryForTarget(const char *target,
|
void cmMakefile::AddLinkLibraryForTarget(const char *target,
|
||||||
@ -665,29 +665,29 @@ void cmMakefile::AddLibrary(const char* lname, int shared,
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
this->GetCacheManager()->AddCacheEntry(ltname.c_str(),"STATIC",
|
this->GetCacheManager()->AddCacheEntry(ltname.c_str(),"STATIC",
|
||||||
"Whether a library is static, shared or module.",
|
"Whether a library is static, shared or module.",
|
||||||
cmCacheManager::INTERNAL);
|
cmCacheManager::INTERNAL);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
this->GetCacheManager()->
|
this->GetCacheManager()->
|
||||||
AddCacheEntry(ltname.c_str(),
|
AddCacheEntry(ltname.c_str(),
|
||||||
"SHARED",
|
"SHARED",
|
||||||
"Whether a library is static, shared or module.",
|
"Whether a library is static, shared or module.",
|
||||||
cmCacheManager::INTERNAL);
|
cmCacheManager::INTERNAL);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
this->GetCacheManager()->
|
this->GetCacheManager()->
|
||||||
AddCacheEntry(ltname.c_str(),
|
AddCacheEntry(ltname.c_str(),
|
||||||
"MODULE",
|
"MODULE",
|
||||||
"Whether a library is static, shared or module.",
|
"Whether a library is static, shared or module.",
|
||||||
cmCacheManager::INTERNAL);
|
cmCacheManager::INTERNAL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this->GetCacheManager()->
|
this->GetCacheManager()->
|
||||||
AddCacheEntry(ltname.c_str(),
|
AddCacheEntry(ltname.c_str(),
|
||||||
"STATIC",
|
"STATIC",
|
||||||
"Whether a library is static, shared or module.",
|
"Whether a library is static, shared or module.",
|
||||||
cmCacheManager::INTERNAL);
|
cmCacheManager::INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -752,6 +752,20 @@ void cmMakefile::AddUtilityCommand(const char* utilityName,
|
|||||||
m_Targets.insert(cmTargets::value_type(utilityName,target));
|
m_Targets.insert(cmTargets::value_type(utilityName,target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmSourceGroup* cmMakefile::GetSourceGroup(const char* name)
|
||||||
|
{
|
||||||
|
// First see if the group exists. If so, replace its regular expression.
|
||||||
|
for(std::vector<cmSourceGroup>::iterator sg = m_SourceGroups.begin();
|
||||||
|
sg != m_SourceGroups.end(); ++sg)
|
||||||
|
{
|
||||||
|
std::string sgName = sg->GetName();
|
||||||
|
if(sgName == name)
|
||||||
|
{
|
||||||
|
return &(*sg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void cmMakefile::AddSourceGroup(const char* name, const char* regex)
|
void cmMakefile::AddSourceGroup(const char* name, const char* regex)
|
||||||
{
|
{
|
||||||
@ -762,9 +776,12 @@ void cmMakefile::AddSourceGroup(const char* name, const char* regex)
|
|||||||
std::string sgName = sg->GetName();
|
std::string sgName = sg->GetName();
|
||||||
if(sgName == name)
|
if(sgName == name)
|
||||||
{
|
{
|
||||||
// We only want to set the regular expression. If there are already
|
if ( regex )
|
||||||
// source files in the group, we don't want to remove them.
|
{
|
||||||
sg->SetGroupRegex(regex);
|
// We only want to set the regular expression. If there are already
|
||||||
|
// source files in the group, we don't want to remove them.
|
||||||
|
sg->SetGroupRegex(regex);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1180,7 +1197,7 @@ bool cmMakefile::IsFunctionBlocked(const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefile::RemoveFunctionBlocker(const char *name,
|
void cmMakefile::RemoveFunctionBlocker(const char *name,
|
||||||
const 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::list<cmFunctionBlocker *>::reverse_iterator pos;
|
std::list<cmFunctionBlocker *>::reverse_iterator pos;
|
||||||
|
@ -239,7 +239,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Add a source group for consideration when adding a new source.
|
* Add a source group for consideration when adding a new source.
|
||||||
*/
|
*/
|
||||||
void AddSourceGroup(const char* name, const char* regex);
|
void AddSourceGroup(const char* name, const char* regex=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an auxiliary directory to the build.
|
* Add an auxiliary directory to the build.
|
||||||
@ -451,6 +451,11 @@ public:
|
|||||||
const std::vector<cmSourceGroup>& GetSourceGroups() const
|
const std::vector<cmSourceGroup>& GetSourceGroups() const
|
||||||
{ return m_SourceGroups; }
|
{ return m_SourceGroups; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the source group
|
||||||
|
*/
|
||||||
|
cmSourceGroup* GetSourceGroup(const char* name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the vector of list files on which this makefile depends
|
* Get the vector of list files on which this makefile depends
|
||||||
*/
|
*/
|
||||||
@ -488,7 +493,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
cmSourceGroup& FindSourceGroup(const char* source,
|
cmSourceGroup& FindSourceGroup(const char* source,
|
||||||
std::vector<cmSourceGroup> &groups);
|
std::vector<cmSourceGroup> &groups);
|
||||||
|
|
||||||
void RegisterData(cmData*);
|
void RegisterData(cmData*);
|
||||||
void RegisterData(const char*, cmData*);
|
void RegisterData(const char*, cmData*);
|
||||||
cmData* LookupData(const char*) const;
|
cmData* LookupData(const char*) const;
|
||||||
@ -533,7 +537,7 @@ protected:
|
|||||||
std::string m_HomeOutputDirectory;
|
std::string m_HomeOutputDirectory;
|
||||||
std::string m_cmCurrentListFile;
|
std::string m_cmCurrentListFile;
|
||||||
|
|
||||||
std::string m_ProjectName; // project name
|
std::string m_ProjectName; // project name
|
||||||
|
|
||||||
// libraries, classes, and executables
|
// libraries, classes, and executables
|
||||||
cmTargets m_Targets;
|
cmTargets m_Targets;
|
||||||
@ -574,8 +578,8 @@ private:
|
|||||||
std::string GetParentListFileName(const char *listFileName);
|
std::string GetParentListFileName(const char *listFileName);
|
||||||
|
|
||||||
void ReadSources(std::ifstream& fin, bool t);
|
void ReadSources(std::ifstream& fin, bool t);
|
||||||
friend class cmMakeDepend; // make depend needs direct access
|
friend class cmMakeDepend; // make depend needs direct access
|
||||||
// to the m_Sources array
|
// to the m_Sources array
|
||||||
void PrintStringVector(const char* s, const std::vector<std::string>& v) const;
|
void PrintStringVector(const char* s, const std::vector<std::string>& v) const;
|
||||||
void AddDefaultDefinitions();
|
void AddDefaultDefinitions();
|
||||||
std::list<cmFunctionBlocker *> m_FunctionBlockers;
|
std::list<cmFunctionBlocker *> m_FunctionBlockers;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -182,7 +182,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Instantiate cmRegularExpression with program=NULL.
|
* Instantiate cmRegularExpression with program=NULL.
|
||||||
*/
|
*/
|
||||||
inline cmRegularExpression ();
|
inline cmRegularExpression ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate cmRegularExpression with compiled char*.
|
* Instantiate cmRegularExpression with compiled char*.
|
||||||
@ -215,7 +215,7 @@ public:
|
|||||||
* Matches the regular expression to the given std string.
|
* Matches the regular expression to the given std string.
|
||||||
* Returns true if found, and sets start and end indexes accordingly.
|
* Returns true if found, and sets start and end indexes accordingly.
|
||||||
*/
|
*/
|
||||||
bool find (std::string const&);
|
bool find (std::string const&);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index to start of first find.
|
* Index to start of first find.
|
||||||
@ -253,7 +253,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Marks the regular expression as invalid.
|
* Marks the regular expression as invalid.
|
||||||
*/
|
*/
|
||||||
inline void set_invalid();
|
inline void set_invalid();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
@ -266,10 +266,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
const char* startp[NSUBEXP];
|
const char* startp[NSUBEXP];
|
||||||
const char* endp[NSUBEXP];
|
const char* endp[NSUBEXP];
|
||||||
char regstart; // Internal use only
|
char regstart; // Internal use only
|
||||||
char reganch; // Internal use only
|
char reganch; // Internal use only
|
||||||
const char* regmust; // Internal use only
|
const char* regmust; // Internal use only
|
||||||
int regmlen; // Internal use only
|
int regmlen; // Internal use only
|
||||||
char* program;
|
char* program;
|
||||||
int progsize;
|
int progsize;
|
||||||
const char* searchstring;
|
const char* searchstring;
|
||||||
@ -290,7 +290,10 @@ inline cmRegularExpression::cmRegularExpression ()
|
|||||||
inline cmRegularExpression::cmRegularExpression (const char* s)
|
inline cmRegularExpression::cmRegularExpression (const char* s)
|
||||||
{
|
{
|
||||||
this->program = 0;
|
this->program = 0;
|
||||||
compile(s);
|
if ( s )
|
||||||
|
{
|
||||||
|
this->compile(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,14 +19,42 @@
|
|||||||
// cmSourceGroupCommand
|
// cmSourceGroupCommand
|
||||||
bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args)
|
bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args)
|
||||||
{
|
{
|
||||||
if(args.size() != 2)
|
if(args.size() < 1)
|
||||||
{
|
{
|
||||||
this->SetError("called with incorrect number of arguments");
|
this->SetError("called with incorrect number of arguments");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( args[1] == "REGULAR_EXPRESSION" && args.size() == 3 )
|
||||||
|
{
|
||||||
|
m_Makefile->AddSourceGroup(args[0].c_str(), args[2].c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( args[1] == "FILES" )
|
||||||
|
{
|
||||||
|
cmSourceGroup* sg = m_Makefile->GetSourceGroup(args[0].c_str());
|
||||||
|
if ( !sg )
|
||||||
|
{
|
||||||
|
m_Makefile->AddSourceGroup(args[0].c_str(), 0);
|
||||||
|
sg = m_Makefile->GetSourceGroup(args[0].c_str());
|
||||||
|
}
|
||||||
|
unsigned int cc;
|
||||||
|
for ( cc = 3; cc < args.size(); cc ++ )
|
||||||
|
{
|
||||||
|
sg->AddSource(args[cc].c_str(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Makefile->AddSourceGroup(args[0].c_str(), args[1].c_str());
|
if ( args.size() == 2 )
|
||||||
|
{
|
||||||
return true;
|
m_Makefile->AddSourceGroup(args[0].c_str(), args[1].c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->SetError("called with incorrect number of arguments");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user