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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename);
|
||||
|
@ -417,10 +437,12 @@ bool cmMakefile::ProcessBuildsystemFile(const char* filename)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this->PushPolicyBarrier();
|
||||
BuildsystemFileScope scope(this);
|
||||
this->ReadListFile(listFile, filename);
|
||||
this->PopPolicyBarrier(!cmSystemTools::GetFatalErrorOccured());
|
||||
if(cmSystemTools::GetFatalErrorOccured())
|
||||
{
|
||||
scope.Quiet();
|
||||
}
|
||||
this->EnforceDirectoryLevelRules();
|
||||
return true;
|
||||
}
|
||||
|
@ -576,6 +598,27 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
|
|||
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)
|
||||
{
|
||||
std::string filenametoread =
|
||||
|
@ -590,10 +633,12 @@ bool cmMakefile::ReadListFile(const char* filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
this->PushPolicyBarrier();
|
||||
ListFileScope scope(this);
|
||||
this->ReadListFile(listFile, filenametoread);
|
||||
this->PopPolicyBarrier(!cmSystemTools::GetFatalErrorOccured());
|
||||
this->ListFileStack.pop_back();
|
||||
if(cmSystemTools::GetFatalErrorOccured())
|
||||
{
|
||||
scope.Quiet();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -968,6 +968,10 @@ private:
|
|||
friend class cmCMakePolicyCommand;
|
||||
class IncludeScope;
|
||||
friend class IncludeScope;
|
||||
class ListFileScope;
|
||||
friend class ListFileScope;
|
||||
class BuildsystemFileScope;
|
||||
friend class BuildsystemFileScope;
|
||||
|
||||
// stack of policy settings
|
||||
struct PolicyStackEntry: public cmPolicies::PolicyMap
|
||||
|
|
Loading…
Reference in New Issue