This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, next has been updated via 6e5d72779f4cfbad2ad281b458914b8c0f914116 (commit) via 6034dc31bccb13b167ee7453bd3693c334e73c7e (commit) via b2679bb29b33a1f828221c31e7553687bbe7ce5b (commit) via 24db937ca324fa439f60a20758b29d3dd9b44bb4 (commit) from dd4fb08a0bfc3179f8f7d1ff5c1e95a2101e04ac (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6e5d72779f4cfbad2ad281b458914b8c0f914116 commit 6e5d72779f4cfbad2ad281b458914b8c0f914116 Merge: dd4fb08 6034dc3 Author: Stephen Kelly <steve...@gmail.com> AuthorDate: Tue Apr 28 18:35:00 2015 -0400 Commit: CMake Topic Stage <kwro...@kitware.com> CommitDate: Tue Apr 28 18:35:00 2015 -0400 Merge topic 'simplify-cmDefinitions-Set' into next 6034dc31 cmDefinitions: Externalize the Set logic. b2679bb2 cmDefinitions: Add an Erase method. 24db937c cmMakefile: Use the Internal class to enclose the VarStack. diff --cc Source/cmMakefile.cxx index 0935383,7180c6c..8754427 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@@ -53,32 -139,13 +139,30 @@@ public }; // default is not to be building executables -cmMakefile::cmMakefile(): Internal(new Internals) +cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) + : Internal(new Internals), + LocalGenerator(localGenerator), + StateSnapshot(localGenerator->GetGlobalGenerator() + ->GetCMakeInstance()->GetState()) { - const cmDefinitions& defs = cmDefinitions(); - const std::set<std::string> globalKeys = defs.LocalKeys(); - this->Internal->VarStack.push(defs); - this->Internal->VarInitStack.push(globalKeys); - this->Internal->VarUsageStack.push(globalKeys); + this->Internal->PushDefinitions(); + this->Internal->VarInitStack.push(std::set<std::string>()); + this->Internal->VarUsageStack.push(std::set<std::string>()); this->Internal->IsSourceFileTryCompile = false; + if (this->LocalGenerator->GetParent()) + { + cmMakefile* parentMf = this->LocalGenerator->GetParent()->GetMakefile(); + this->StateSnapshot = + this->GetState()->CreateSnapshot(parentMf->StateSnapshot); + } + else + { + this->StateSnapshot = + this->GetState()->CreateSnapshot(this->StateSnapshot); + } + + // Initialize these first since AddDefaultDefinitions calls AddDefinition this->WarnUnused = false; this->CheckSystemVars = false; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6034dc31bccb13b167ee7453bd3693c334e73c7e commit 6034dc31bccb13b167ee7453bd3693c334e73c7e Author: Stephen Kelly <steve...@gmail.com> AuthorDate: Sat Apr 25 16:36:48 2015 +0200 Commit: Stephen Kelly <steve...@gmail.com> CommitDate: Wed Apr 29 00:32:42 2015 +0200 cmDefinitions: Externalize the Set logic. diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 58500c9..032a96e 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -11,6 +11,8 @@ ============================================================================*/ #include "cmDefinitions.h" +#include <assert.h> + //---------------------------------------------------------------------------- cmDefinitions::Def cmDefinitions::NoDef; @@ -49,16 +51,7 @@ const char* cmDefinitions::Get(const std::string& key) void cmDefinitions::Set(const std::string& key, const char* value) { Def def(value); - if(this->Up || def.Exists) - { - // In lower scopes we store keys, defined or not. - this->Map[key] = def; - } - else - { - // In the top-most scope we need not store undefined keys. - this->Map.erase(key); - } + this->Map[key] = def; } void cmDefinitions::Erase(const std::string& key) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9da01db..7180c6c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -78,7 +78,15 @@ public: void RemoveDefinition(std::string const& name) { - this->VarStack.top().Set(name, 0); + if (this->VarStack.size() > 1) + { + // In lower scopes we store keys, defined or not. + this->VarStack.top().Set(name, 0); + } + else + { + this->VarStack.top().Erase(name); + } } std::set<std::string> LocalKeys() const http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b2679bb29b33a1f828221c31e7553687bbe7ce5b commit b2679bb29b33a1f828221c31e7553687bbe7ce5b Author: Stephen Kelly <steve...@gmail.com> AuthorDate: Sat Apr 25 16:33:26 2015 +0200 Commit: Stephen Kelly <steve...@gmail.com> CommitDate: Wed Apr 29 00:29:21 2015 +0200 cmDefinitions: Add an Erase method. diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index abb46b3..58500c9 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -61,6 +61,11 @@ void cmDefinitions::Set(const std::string& key, const char* value) } } +void cmDefinitions::Erase(const std::string& key) +{ + this->Map.erase(key); +} + //---------------------------------------------------------------------------- std::set<std::string> cmDefinitions::LocalKeys() const { diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 83cd0d9..13f885d 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -40,6 +40,8 @@ public: /** Set (or unset if null) a value associated with a key. */ void Set(const std::string& key, const char* value); + void Erase(const std::string& key); + /** Get the set of all local keys. */ std::set<std::string> LocalKeys() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=24db937ca324fa439f60a20758b29d3dd9b44bb4 commit 24db937ca324fa439f60a20758b29d3dd9b44bb4 Author: Stephen Kelly <steve...@gmail.com> AuthorDate: Sat Apr 25 16:03:04 2015 +0200 Commit: Stephen Kelly <steve...@gmail.com> CommitDate: Wed Apr 29 00:27:41 2015 +0200 cmMakefile: Use the Internal class to enclose the VarStack. Put knowledge of the implementation details in one place. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c77a90c..9da01db 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -50,16 +50,92 @@ public: std::stack<std::set<std::string> > VarInitStack; std::stack<std::set<std::string> > VarUsageStack; bool IsSourceFileTryCompile; + + void PushDefinitions() + { + cmDefinitions* parent = 0; + if (!this->VarStack.empty()) + { + parent = &this->VarStack.top(); + } + this->VarStack.push(cmDefinitions(parent)); + } + + void InitializeDefinitions(cmMakefile* parent) + { + this->VarStack.top() = parent->Internal->VarStack.top().Closure(); + } + + const char* GetDefinition(std::string const& name) + { + return this->VarStack.top().Get(name); + } + + void SetDefinition(std::string const& name, std::string const& value) + { + this->VarStack.top().Set(name, value.c_str()); + } + + void RemoveDefinition(std::string const& name) + { + this->VarStack.top().Set(name, 0); + } + + std::set<std::string> LocalKeys() const + { + return this->VarStack.top().LocalKeys(); + } + + std::set<std::string> ClosureKeys() const + { + return this->VarStack.top().ClosureKeys(); + } + + void PopDefinitions() + { + this->VarStack.pop(); + } + + bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) + { + cmDefinitions& cur = this->VarStack.top(); + if(cmDefinitions* up = cur.GetParent()) + { + // First localize the definition in the current scope. + cur.Get(var); + + // Now update the definition in the parent scope. + up->Set(var, varDef); + } + else if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent()) + { + // Update the definition in the parent directory top scope. This + // directory's scope was initialized by the closure of the parent + // scope, so we do not need to localize the definition first. + cmMakefile* parent = plg->GetMakefile(); + if (varDef) + { + parent->AddDefinition(var, varDef); + } + else + { + parent->RemoveDefinition(var); + } + } + else + { + return false; + } + return true; + } }; // default is not to be building executables cmMakefile::cmMakefile(): Internal(new Internals) { - const cmDefinitions& defs = cmDefinitions(); - const std::set<std::string> globalKeys = defs.LocalKeys(); - this->Internal->VarStack.push(defs); - this->Internal->VarInitStack.push(globalKeys); - this->Internal->VarUsageStack.push(globalKeys); + this->Internal->PushDefinitions(); + this->Internal->VarInitStack.push(std::set<std::string>()); + this->Internal->VarUsageStack.push(std::set<std::string>()); this->Internal->IsSourceFileTryCompile = false; // Initialize these first since AddDefaultDefinitions calls AddDefinition @@ -1499,7 +1575,7 @@ void cmMakefile::InitializeFromParent() cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile(); // Initialize definitions with the closure of the parent scope. - this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure(); + this->Internal->InitializeDefinitions(parent); this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", this->GetCurrentSourceDirectory()); @@ -1699,7 +1775,7 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value) return; } - this->Internal->VarStack.top().Set(name, value); + this->Internal->SetDefinition(name, value); if (!this->Internal->VarUsageStack.empty() && this->VariableInitialized(name)) { @@ -1769,13 +1845,13 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, this->GetState()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, type); // if there was a definition then remove it - this->Internal->VarStack.top().Set(name, 0); + this->Internal->RemoveDefinition(name); } void cmMakefile::AddDefinition(const std::string& name, bool value) { - this->Internal->VarStack.top().Set(name, value? "ON" : "OFF"); + this->Internal->SetDefinition(name, value ? "ON" : "OFF"); if (!this->Internal->VarUsageStack.empty() && this->VariableInitialized(name)) { @@ -1799,8 +1875,7 @@ void cmMakefile::CheckForUnusedVariables() const { return; } - const cmDefinitions& defs = this->Internal->VarStack.top(); - const std::set<std::string>& locals = defs.LocalKeys(); + const std::set<std::string>& locals = this->Internal->LocalKeys(); std::set<std::string>::const_iterator it = locals.begin(); for (; it != locals.end(); ++it) { @@ -1874,7 +1949,7 @@ void cmMakefile::CheckForUnused(const char* reason, void cmMakefile::RemoveDefinition(const std::string& name) { - this->Internal->VarStack.top().Set(name, 0); + this->Internal->RemoveDefinition(name); if (!this->Internal->VarUsageStack.empty() && this->VariableInitialized(name)) { @@ -2347,7 +2422,7 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const bool cmMakefile::IsDefinitionSet(const std::string& name) const { - const char* def = this->Internal->VarStack.top().Get(name); + const char* def = this->Internal->GetDefinition(name); this->Internal->VarUsageStack.top().insert(name); if(!def) { @@ -2373,7 +2448,7 @@ const char* cmMakefile::GetDefinition(const std::string& name) const { this->Internal->VarUsageStack.top().insert(name); } - const char* def = this->Internal->VarStack.top().Get(name); + const char* def = this->Internal->GetDefinition(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2413,8 +2488,7 @@ std::vector<std::string> cmMakefile std::vector<std::string> res; if ( !cacheonly ) { - std::set<std::string> definitions = - this->Internal->VarStack.top().ClosureKeys(); + std::set<std::string> definitions = this->Internal->ClosureKeys(); res.insert(res.end(), definitions.begin(), definitions.end()); } std::vector<std::string> cacheKeys = @@ -4329,10 +4403,9 @@ std::string cmMakefile::GetListFileStack() const void cmMakefile::PushScope() { - cmDefinitions* parent = &this->Internal->VarStack.top(); + this->Internal->PushDefinitions(); const std::set<std::string>& init = this->Internal->VarInitStack.top(); const std::set<std::string>& usage = this->Internal->VarUsageStack.top(); - this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); @@ -4353,10 +4426,9 @@ void cmMakefile::PopScope() this->PopLoopBlockBarrier(); - cmDefinitions* current = &this->Internal->VarStack.top(); std::set<std::string> init = this->Internal->VarInitStack.top(); std::set<std::string> usage = this->Internal->VarUsageStack.top(); - const std::set<std::string>& locals = current->LocalKeys(); + const std::set<std::string>& locals = this->Internal->LocalKeys(); // Remove initialization and usage information for variables in the local // scope. std::set<std::string>::const_iterator it = locals.begin(); @@ -4372,7 +4444,8 @@ void cmMakefile::PopScope() usage.erase(*it); } } - this->Internal->VarStack.pop(); + + this->Internal->PopDefinitions(); this->Internal->VarInitStack.pop(); this->Internal->VarUsageStack.pop(); // Push initialization and usage up to the parent scope. @@ -4387,31 +4460,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef) return; } - cmDefinitions& cur = this->Internal->VarStack.top(); - if(cmDefinitions* up = cur.GetParent()) - { - // First localize the definition in the current scope. - cur.Get(var); - - // Now update the definition in the parent scope. - up->Set(var, varDef); - } - else if(cmLocalGenerator* plg = this->LocalGenerator->GetParent()) - { - // Update the definition in the parent directory top scope. This - // directory's scope was initialized by the closure of the parent - // scope, so we do not need to localize the definition first. - cmMakefile* parent = plg->GetMakefile(); - if (varDef) - { - parent->AddDefinition(var, varDef); - } - else - { - parent->RemoveDefinition(var); - } - } - else + if (!this->Internal->RaiseScope(var, varDef, this)) { std::ostringstream m; m << "Cannot set \"" << var << "\": current scope has no parent."; ----------------------------------------------------------------------- Summary of changes: Source/cmDefinitions.cxx | 18 +++--- Source/cmDefinitions.h | 2 + Source/cmMakefile.cxx | 149 ++++++++++++++++++++++++++++++++-------------- 3 files changed, 113 insertions(+), 56 deletions(-) hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/mailman/listinfo/cmake-commits