Try to improve source group interface
This commit is contained in:
parent
77616437d1
commit
a518fed4e3
|
@ -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)
|
||||
{
|
||||
|
@ -761,10 +775,13 @@ void cmMakefile::AddSourceGroup(const char* name, const char* regex)
|
|||
{
|
||||
std::string sgName = sg->GetName();
|
||||
if(sgName == name)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -39,6 +39,11 @@
|
|||
|
||||
// cmRegularExpression -- Copies the given regular expression.
|
||||
cmRegularExpression::cmRegularExpression (const cmRegularExpression& rxp) {
|
||||
if ( !rxp.program )
|
||||
{
|
||||
this->program = 0;
|
||||
return;
|
||||
}
|
||||
int ind;
|
||||
this->progsize = rxp.progsize; // Copy regular expression size
|
||||
this->program = new char[this->progsize]; // Allocate storage
|
||||
|
@ -848,8 +853,13 @@ bool cmRegularExpression::find (const char* string) {
|
|||
|
||||
this->searchstring = string;
|
||||
|
||||
if (!this->program)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check validity of program.
|
||||
if (!this->program || UCHARAT(this->program) != MAGIC) {
|
||||
if (UCHARAT(this->program) != MAGIC) {
|
||||
//RAISE Error, SYM(cmRegularExpression), SYM(Internal_Error),
|
||||
printf ("cmRegularExpression::find(): Compiled regular expression corrupted.\n");
|
||||
return 0;
|
||||
|
|
|
@ -290,7 +290,10 @@ inline cmRegularExpression::cmRegularExpression ()
|
|||
inline cmRegularExpression::cmRegularExpression (const char* s)
|
||||
{
|
||||
this->program = 0;
|
||||
compile(s);
|
||||
if ( s )
|
||||
{
|
||||
this->compile(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
m_Makefile->AddSourceGroup(args[0].c_str(), args[1].c_str());
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue