Try to improve source group interface

This commit is contained in:
Andy Cedilnik 2002-10-04 18:16:13 -04:00
parent 77616437d1
commit a518fed4e3
5 changed files with 645 additions and 583 deletions

View File

@ -141,7 +141,7 @@ void cmMakefile::Print() const
m_cmStartDirectory.c_str() << std::endl;
std::cout << " m_cmHomeDirectory; " <<
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_IncludeDirectories;", m_IncludeDirectories);
this->PrintStringVector("m_LinkDirectories", m_LinkDirectories);
@ -193,12 +193,12 @@ void cmMakefile::ExecuteCommand(std::string const &name,
}
if(!usedCommand->InitialPass(expandedArguments))
{
std::string error;
error = usedCommand->GetName();
error += ": Error : \n";
error += usedCommand->GetError();
error += " from CMakeLists.txt file in directory: ";
error += m_cmCurrentDirectory;
std::string error;
error = usedCommand->GetName();
error += ": Error : \n";
error += usedCommand->GetError();
error += " from CMakeLists.txt file in directory: ";
error += m_cmCurrentDirectory;
cmSystemTools::Error(error.c_str());
}
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
std::string parentList = this->GetParentListFileName(filename);
if (parentList != "")
{
std::string srcdir = m_cmCurrentDirectory;
{
std::string srcdir = m_cmCurrentDirectory;
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_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(pos == std::string::npos)
{
// if not found, oops
if(pos == std::string::npos)
{
cmSystemTools::Error("Trailing slash not found");
}
}
this->ReadListFile(parentList.c_str());
this->ReadListFile(parentList.c_str());
// restore the current directory
m_cmCurrentDirectory = srcdir;
m_CurrentOutputDirectory = bindir;
}
// restore the current directory
m_cmCurrentDirectory = srcdir;
m_CurrentOutputDirectory = bindir;
}
}
// 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)
{
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,
@ -665,29 +665,29 @@ void cmMakefile::AddLibrary(const char* lname, int shared,
{
case 0:
this->GetCacheManager()->AddCacheEntry(ltname.c_str(),"STATIC",
"Whether a library is static, shared or module.",
cmCacheManager::INTERNAL);
"Whether a library is static, shared or module.",
cmCacheManager::INTERNAL);
break;
case 1:
this->GetCacheManager()->
AddCacheEntry(ltname.c_str(),
"SHARED",
"Whether a library is static, shared or module.",
cmCacheManager::INTERNAL);
AddCacheEntry(ltname.c_str(),
"SHARED",
"Whether a library is static, shared or module.",
cmCacheManager::INTERNAL);
break;
case 2:
this->GetCacheManager()->
AddCacheEntry(ltname.c_str(),
"MODULE",
"Whether a library is static, shared or module.",
cmCacheManager::INTERNAL);
AddCacheEntry(ltname.c_str(),
"MODULE",
"Whether a library is static, shared or module.",
cmCacheManager::INTERNAL);
break;
default:
this->GetCacheManager()->
AddCacheEntry(ltname.c_str(),
"STATIC",
"Whether a library is static, shared or module.",
cmCacheManager::INTERNAL);
AddCacheEntry(ltname.c_str(),
"STATIC",
"Whether a library is static, shared or module.",
cmCacheManager::INTERNAL);
}
}
@ -752,6 +752,20 @@ void cmMakefile::AddUtilityCommand(const char* utilityName,
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)
{
@ -762,9 +776,12 @@ void cmMakefile::AddSourceGroup(const char* name, const char* regex)
std::string sgName = sg->GetName();
if(sgName == name)
{
// 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);
if ( 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;
}
}
@ -1180,7 +1197,7 @@ bool cmMakefile::IsFunctionBlocked(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
std::list<cmFunctionBlocker *>::reverse_iterator pos;

View File

@ -239,7 +239,7 @@ public:
/**
* 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.
@ -451,6 +451,11 @@ public:
const std::vector<cmSourceGroup>& GetSourceGroups() const
{ return m_SourceGroups; }
/**
* Get the source group
*/
cmSourceGroup* GetSourceGroup(const char* name);
/**
* Get the vector of list files on which this makefile depends
*/
@ -488,7 +493,6 @@ public:
*/
cmSourceGroup& FindSourceGroup(const char* source,
std::vector<cmSourceGroup> &groups);
void RegisterData(cmData*);
void RegisterData(const char*, cmData*);
cmData* LookupData(const char*) const;
@ -533,7 +537,7 @@ protected:
std::string m_HomeOutputDirectory;
std::string m_cmCurrentListFile;
std::string m_ProjectName; // project name
std::string m_ProjectName; // project name
// libraries, classes, and executables
cmTargets m_Targets;
@ -574,8 +578,8 @@ private:
std::string GetParentListFileName(const char *listFileName);
void ReadSources(std::ifstream& fin, bool t);
friend class cmMakeDepend; // make depend needs direct access
// to the m_Sources array
friend class cmMakeDepend; // make depend needs direct access
// to the m_Sources array
void PrintStringVector(const char* s, const std::vector<std::string>& v) const;
void AddDefaultDefinitions();
std::list<cmFunctionBlocker *> m_FunctionBlockers;

File diff suppressed because it is too large Load Diff

View File

@ -182,7 +182,7 @@ public:
/**
* Instantiate cmRegularExpression with program=NULL.
*/
inline cmRegularExpression ();
inline cmRegularExpression ();
/**
* Instantiate cmRegularExpression with compiled char*.
@ -215,7 +215,7 @@ public:
* Matches the regular expression to the given std string.
* 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.
@ -253,7 +253,7 @@ public:
/**
* Marks the regular expression as invalid.
*/
inline void set_invalid();
inline void set_invalid();
/**
* Destructor.
@ -266,10 +266,10 @@ public:
private:
const char* startp[NSUBEXP];
const char* endp[NSUBEXP];
char regstart; // Internal use only
char reganch; // Internal use only
const char* regmust; // Internal use only
int regmlen; // Internal use only
char regstart; // Internal use only
char reganch; // Internal use only
const char* regmust; // Internal use only
int regmlen; // Internal use only
char* program;
int progsize;
const char* searchstring;
@ -290,7 +290,10 @@ inline cmRegularExpression::cmRegularExpression ()
inline cmRegularExpression::cmRegularExpression (const char* s)
{
this->program = 0;
compile(s);
if ( s )
{
this->compile(s);
}
}
/**

View File

@ -19,14 +19,42 @@
// cmSourceGroupCommand
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");
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());
return true;
if ( args.size() == 2 )
{
m_Makefile->AddSourceGroup(args[0].c_str(), args[1].c_str());
return true;
}
this->SetError("called with incorrect number of arguments");
return false;
}