diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-06-21 20:50:13 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-06-30 21:14:18 (GMT) |
commit | 92cecd936999f9a4c67332d1aeaba3ff120fbbc2 (patch) | |
tree | 76c5f693dd326f42450422f5e1af865c62b0cb7b | |
parent | 276c62253e3f25eda4acbf0049a70c7d622c9ea2 (diff) | |
download | CMake-92cecd936999f9a4c67332d1aeaba3ff120fbbc2.zip CMake-92cecd936999f9a4c67332d1aeaba3ff120fbbc2.tar.gz CMake-92cecd936999f9a4c67332d1aeaba3ff120fbbc2.tar.bz2 |
cmMakefile: Add automatic scopes to listfile readers.
-rw-r--r-- | Source/cmMakefile.cxx | 57 | ||||
-rw-r--r-- | Source/cmMakefile.h | 4 |
2 files changed, 55 insertions, 6 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 5225605..a10f99c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 85f117b..64783e5 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -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 |