summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-07-02 13:06:13 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-07-02 13:06:13 (GMT)
commit5647b243be2c5016dfd558d17547f0ddf89046f0 (patch)
tree00432a024588b8cb93b78b83efa8e3e3f5dcabf0 /Source
parent8c492cadeb67522712369415bcfb734d83996d56 (diff)
parent48c6a92b286522cf350412d6dd3219b263e9ab5b (diff)
downloadCMake-5647b243be2c5016dfd558d17547f0ddf89046f0.zip
CMake-5647b243be2c5016dfd558d17547f0ddf89046f0.tar.gz
CMake-5647b243be2c5016dfd558d17547f0ddf89046f0.tar.bz2
Merge topic 'clean-up-cmMakefile'
48c6a92b cmMakefile: Merge two Scope types and instances. e28e110d cmMakefile: Rename a variable. 3f5200ec cmMakefile: Expand the scope of scoped buildsystem file state. 0a34ea59 cmMakefile: Compute the filename processed in a scope. be5997ef cmMakefile: Inline ProcessBuildsystemFile into only caller. 5bf9bfda cmMakefile: Don't use string comparison to check directory level. f346d88d cmMakefile: Avoid invoking EnforceDirectoryLevelRules. b6614031 cmMakefile: Add filename to ReadListFile auto scopes. 6708d216 cmMakefile: Remove IncludeScope Quiet call. 0818737c cmMakefile: Make listfile scopes responsible for logical checks. dd7e4275 cmMakefile: Move the lexical scope. 92cecd93 cmMakefile: Add automatic scopes to listfile readers. 276c6225 cmMakefile: Move the IncludeScope to where it is used.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalGenerator.cxx1
-rw-r--r--Source/cmMakefile.cxx131
-rw-r--r--Source/cmMakefile.h22
3 files changed, 80 insertions, 74 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 23ab93d..383984d 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1106,6 +1106,7 @@ void cmGlobalGenerator::Configure()
// now do it
lg->GetMakefile()->Configure();
+ lg->GetMakefile()->EnforceDirectoryLevelRules();
// update the cache entry for the number of local generators, this is used
// for progress
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index a3ba134..cdcf88c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -460,11 +460,13 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
// The included file cannot pop our policy scope.
this->Makefile->PushPolicyBarrier();
this->Makefile->ListFileStack.push_back(filenametoread);
+ this->Makefile->PushFunctionBlockerBarrier();
}
//----------------------------------------------------------------------------
cmMakefile::IncludeScope::~IncludeScope()
{
+ this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
// Enforce matching policy scopes inside the included file.
this->Makefile->PopPolicyBarrier(this->ReportError);
@@ -532,26 +534,6 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
}
}
-bool cmMakefile::ProcessBuildsystemFile(const char* filename)
-{
- this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename);
- std::string curSrc = this->GetCurrentSourceDirectory();
-
- this->ListFileStack.push_back(filename);
-
- cmListFile listFile;
- if (!listFile.ParseFile(filename, curSrc == this->GetHomeDirectory(), this))
- {
- return false;
- }
-
- this->PushPolicyBarrier();
- this->ReadListFile(listFile, filename);
- this->PopPolicyBarrier(!cmSystemTools::GetFatalErrorOccured());
- this->EnforceDirectoryLevelRules();
- return true;
-}
-
bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
{
this->AddDefinition("CMAKE_PARENT_LIST_FILE",
@@ -565,7 +547,6 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
cmListFile listFile;
if (!listFile.ParseFile(filenametoread.c_str(), false, this))
{
- incScope.Quiet();
return false;
}
this->ReadListFile(listFile, filenametoread);
@@ -576,13 +557,37 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
return true;
}
+class cmMakefile::ListFileScope
+{
+public:
+ ListFileScope(cmMakefile* mf, std::string const& filenametoread)
+ : Makefile(mf), ReportError(true)
+ {
+ this->Makefile->ListFileStack.push_back(filenametoread);
+ this->Makefile->PushPolicyBarrier();
+ this->Makefile->PushFunctionBlockerBarrier();
+ }
+
+ ~ListFileScope()
+ {
+ this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
+ 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 =
cmSystemTools::CollapseFullPath(filename,
this->GetCurrentSourceDirectory());
- this->ListFileStack.push_back(filenametoread);
+ ListFileScope scope(this, filenametoread);
cmListFile listFile;
if (!listFile.ParseFile(filenametoread.c_str(), false, this))
@@ -590,10 +595,11 @@ bool cmMakefile::ReadListFile(const char* filename)
return false;
}
- this->PushPolicyBarrier();
this->ReadListFile(listFile, filenametoread);
- this->PopPolicyBarrier(!cmSystemTools::GetFatalErrorOccured());
- this->ListFileStack.pop_back();
+ if(cmSystemTools::GetFatalErrorOccured())
+ {
+ scope.Quiet();
+ }
return true;
}
@@ -616,9 +622,6 @@ void cmMakefile::ReadListFile(cmListFile const& listFile,
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
- // Enforce balanced blocks (if/endif, function/endfunction, etc.).
- LexicalPushPop lexScope(this);
-
// Run the parsed commands.
const size_t numberFunctions = listFile.Functions.size();
for(size_t i =0; i < numberFunctions; ++i)
@@ -627,8 +630,6 @@ void cmMakefile::ReadListFile(cmListFile const& listFile,
this->ExecuteCommand(listFile.Functions[i],status);
if(cmSystemTools::GetFatalErrorOccured())
{
- // Exit early due to error.
- lexScope.Quiet();
break;
}
if(status.GetReturnInvoked())
@@ -1625,17 +1626,21 @@ bool cmMakefile::IsRootMakefile() const
return !this->StateSnapshot.GetBuildsystemDirectoryParent().IsValid();
}
-//----------------------------------------------------------------------------
-class cmMakefileCurrent
+class cmMakefile::BuildsystemFileScope
{
- cmGlobalGenerator* GG;
- cmMakefile* MF;
- cmState::Snapshot Snapshot;
public:
- cmMakefileCurrent(cmMakefile* mf)
- {
+ BuildsystemFileScope(cmMakefile* mf)
+ : Makefile(mf), ReportError(true)
+ {
+ std::string currentStart =
+ this->Makefile->StateSnapshot.GetCurrentSourceDirectory();
+ currentStart += "/CMakeLists.txt";
+ this->Makefile->ListFileStack.push_back(currentStart);
+ this->Makefile->PushPolicyBarrier();
+ this->Makefile->PushFunctionBlockerBarrier();
+
this->GG = mf->GetGlobalGenerator();
- this->MF = this->GG->GetCurrentMakefile();
+ this->CurrentMakefile = this->GG->GetCurrentMakefile();
this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot();
this->GG->GetCMakeInstance()->SetCurrentSnapshot(
this->GG->GetCMakeInstance()->GetCurrentSnapshot());
@@ -1643,21 +1648,32 @@ public:
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->GG->GetFileLockPool().PushFileScope();
#endif
- }
- ~cmMakefileCurrent()
- {
+ }
+
+ ~BuildsystemFileScope()
+ {
+ this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
+ this->Makefile->PopPolicyBarrier(this->ReportError);
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->GG->GetFileLockPool().PopFileScope();
#endif
- this->GG->SetCurrentMakefile(this->MF);
+ this->GG->SetCurrentMakefile(this->CurrentMakefile);
this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot);
- }
+ }
+
+ void Quiet() { this->ReportError = false; }
+private:
+ cmMakefile* Makefile;
+ cmGlobalGenerator* GG;
+ cmMakefile* CurrentMakefile;
+ cmState::Snapshot Snapshot;
+ bool ReportError;
};
//----------------------------------------------------------------------------
void cmMakefile::Configure()
{
- cmMakefileCurrent cmf(this);
+ BuildsystemFileScope scope(this);
// make sure the CMakeFiles dir is there
std::string filesDir = this->StateSnapshot.GetCurrentBinaryDirectory();
@@ -1667,7 +1683,19 @@ void cmMakefile::Configure()
std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory();
currentStart += "/CMakeLists.txt";
assert(cmSystemTools::FileExists(currentStart.c_str(), true));
- this->ProcessBuildsystemFile(currentStart.c_str());
+ this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str());
+
+ cmListFile listFile;
+ if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(), this))
+ {
+ this->SetConfigured();
+ return;
+ }
+ this->ReadListFile(listFile, currentStart);
+ if(cmSystemTools::GetFatalErrorOccured())
+ {
+ scope.Quiet();
+ }
// at the end handle any old style subdirs
std::vector<cmMakefile*> subdirs = this->UnConfiguredDirectories;
@@ -3477,19 +3505,6 @@ cmMakefile::RemoveFunctionBlocker(cmFunctionBlocker* fb,
return cmsys::auto_ptr<cmFunctionBlocker>();
}
-//----------------------------------------------------------------------------
-cmMakefile::LexicalPushPop::LexicalPushPop(cmMakefile* mf):
- Makefile(mf), ReportError(true)
-{
- this->Makefile->PushFunctionBlockerBarrier();
-}
-
-//----------------------------------------------------------------------------
-cmMakefile::LexicalPushPop::~LexicalPushPop()
-{
- this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
-}
-
const char* cmMakefile::GetHomeDirectory() const
{
return this->GetCMakeInstance()->GetHomeDirectory();
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 85f117b..aa70c72 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -100,19 +100,6 @@ public:
cmsys::auto_ptr<cmFunctionBlocker>
RemoveFunctionBlocker(cmFunctionBlocker* fb, const cmListFileFunction& lff);
- /** Push/pop a lexical (function blocker) barrier automatically. */
- class LexicalPushPop
- {
- public:
- LexicalPushPop(cmMakefile* mf);
- ~LexicalPushPop();
- void Quiet() { this->ReportError = false; }
- private:
- cmMakefile* Makefile;
- bool ReportError;
- };
- friend class LexicalPushPop;
-
/**
* Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process.
@@ -838,6 +825,8 @@ public:
std::string GetExecutionFilePath() const;
+ void EnforceDirectoryLevelRules() const;
+
protected:
// add link libraries and directories to the target
void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
@@ -968,6 +957,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
@@ -984,9 +977,6 @@ private:
cmPolicies::PolicyStatus
GetPolicyStatusInternal(cmPolicies::PolicyID id) const;
- // Enforce rules about CMakeLists.txt files.
- void EnforceDirectoryLevelRules() const;
-
// CMP0053 == old
cmake::MessageType ExpandVariablesInStringOld(
std::string& errorstr,