cmMakefile: Add automatic scopes to listfile readers.
This commit is contained in:
parent
276c62253e
commit
92cecd9369
|
@ -405,6 +405,26 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class cmMakefile::BuildsystemFileScope
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BuildsystemFileScope(cmMakefile* mf)
|
||||||
|
: Makefile(mf), ReportError(true)
|
||||||
|
{
|
||||||
|
this->Makefile->PushPolicyBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
~BuildsystemFileScope()
|
||||||
|
{
|
||||||
|
this->Makefile->PopPolicyBarrier(this->ReportError);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Quiet() { this->ReportError = false; }
|
||||||
|
private:
|
||||||
|
cmMakefile* Makefile;
|
||||||
|
bool ReportError;
|
||||||
|
};
|
||||||
|
|
||||||
bool cmMakefile::ProcessBuildsystemFile(const char* filename)
|
bool cmMakefile::ProcessBuildsystemFile(const char* filename)
|
||||||
{
|
{
|
||||||
this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename);
|
this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename);
|
||||||
|
@ -417,10 +437,12 @@ bool cmMakefile::ProcessBuildsystemFile(const char* filename)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
BuildsystemFileScope scope(this);
|
||||||
this->PushPolicyBarrier();
|
|
||||||
this->ReadListFile(listFile, filename);
|
this->ReadListFile(listFile, filename);
|
||||||
this->PopPolicyBarrier(!cmSystemTools::GetFatalErrorOccured());
|
if(cmSystemTools::GetFatalErrorOccured())
|
||||||
|
{
|
||||||
|
scope.Quiet();
|
||||||
|
}
|
||||||
this->EnforceDirectoryLevelRules();
|
this->EnforceDirectoryLevelRules();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -576,6 +598,27 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class cmMakefile::ListFileScope
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ListFileScope(cmMakefile* mf)
|
||||||
|
: Makefile(mf), ReportError(true)
|
||||||
|
{
|
||||||
|
this->Makefile->PushPolicyBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
~ListFileScope()
|
||||||
|
{
|
||||||
|
this->Makefile->PopPolicyBarrier(this->ReportError);
|
||||||
|
this->Makefile->ListFileStack.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Quiet() { this->ReportError = false; }
|
||||||
|
private:
|
||||||
|
cmMakefile* Makefile;
|
||||||
|
bool ReportError;
|
||||||
|
};
|
||||||
|
|
||||||
bool cmMakefile::ReadListFile(const char* filename)
|
bool cmMakefile::ReadListFile(const char* filename)
|
||||||
{
|
{
|
||||||
std::string filenametoread =
|
std::string filenametoread =
|
||||||
|
@ -590,10 +633,12 @@ bool cmMakefile::ReadListFile(const char* filename)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->PushPolicyBarrier();
|
ListFileScope scope(this);
|
||||||
this->ReadListFile(listFile, filenametoread);
|
this->ReadListFile(listFile, filenametoread);
|
||||||
this->PopPolicyBarrier(!cmSystemTools::GetFatalErrorOccured());
|
if(cmSystemTools::GetFatalErrorOccured())
|
||||||
this->ListFileStack.pop_back();
|
{
|
||||||
|
scope.Quiet();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -968,6 +968,10 @@ private:
|
||||||
friend class cmCMakePolicyCommand;
|
friend class cmCMakePolicyCommand;
|
||||||
class IncludeScope;
|
class IncludeScope;
|
||||||
friend class IncludeScope;
|
friend class IncludeScope;
|
||||||
|
class ListFileScope;
|
||||||
|
friend class ListFileScope;
|
||||||
|
class BuildsystemFileScope;
|
||||||
|
friend class BuildsystemFileScope;
|
||||||
|
|
||||||
// stack of policy settings
|
// stack of policy settings
|
||||||
struct PolicyStackEntry: public cmPolicies::PolicyMap
|
struct PolicyStackEntry: public cmPolicies::PolicyMap
|
||||||
|
|
Loading…
Reference in New Issue