[Cmake-commits] CMake branch, next, updated. v3.3.1-2350-g29dfc9f
Stephen Kelly
steveire at gmail.com
Sun Aug 23 13:05:39 EDT 2015
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 29dfc9fdd943f4f651ad6f293a30528209af847b (commit)
via eb47176870eedef7af8b53d98887d4326cb509de (commit)
via d7fc7c3a403170035359e8e3b173725a04b6c1ff (commit)
via bff27391a91d1410ef33187c0c35acc0a709720d (commit)
from c7501577fbc81d257017a5edfe0520da67e226eb (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=29dfc9fdd943f4f651ad6f293a30528209af847b
commit 29dfc9fdd943f4f651ad6f293a30528209af847b
Merge: c750157 eb47176
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Aug 23 13:05:38 2015 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun Aug 23 13:05:38 2015 -0400
Merge topic 'cmState-definitions' into next
eb471768 cmState: Reserve the number of cmLinkedTree nodes if known.
d7fc7c3a cmLinkedTree: Add API for size query and reserve.
bff27391 cmState: Host variable definitions.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eb47176870eedef7af8b53d98887d4326cb509de
commit eb47176870eedef7af8b53d98887d4326cb509de
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jun 21 13:05:15 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Aug 23 19:05:13 2015 +0200
cmState: Reserve the number of cmLinkedTree nodes if known.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index cda26cd..a19a074 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1141,6 +1141,42 @@ void cmGlobalGenerator::Configure()
this->BinaryDirectories.insert(
this->CMakeInstance->GetHomeOutputDirectory());
+ if (const char *numStr =
+ this->GetCMakeInstance()->GetState()
+ ->GetInitializedCacheValue("CMAKE_NUMBER_OF_DEFINITION_STATES"))
+ {
+ int num = atoi(numStr);
+ this->GetCMakeInstance()->GetState()->ReserveDefinitions(num);
+ }
+ if (const char *numStr =
+ this->GetCMakeInstance()->GetState()
+ ->GetInitializedCacheValue("CMAKE_NUMBER_OF_SNAPSHOT_STATES"))
+ {
+ int num = atoi(numStr);
+ this->GetCMakeInstance()->GetState()->ReserveSnapshots(num);
+ }
+ if (const char *numStr =
+ this->GetCMakeInstance()->GetState()
+ ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LISTFILE_STATES"))
+ {
+ int num = atoi(numStr);
+ this->GetCMakeInstance()->GetState()->ReserveListFiles(num);
+ }
+ if (const char *numStr =
+ this->GetCMakeInstance()->GetState()
+ ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LOCAL_GENERATORS"))
+ {
+ int num = atoi(numStr);
+ this->GetCMakeInstance()->GetState()->ReserveDirectories(num);
+ }
+ if (const char *numStr =
+ this->GetCMakeInstance()->GetState()
+ ->GetInitializedCacheValue("CMAKE_NUMBER_OF_POLICY_STATES"))
+ {
+ int num = atoi(numStr);
+ this->GetCMakeInstance()->GetState()->ReservePolicies(num);
+ }
+
// now do it
lg->GetMakefile()->Configure();
lg->GetMakefile()->EnforceDirectoryLevelRules();
@@ -1153,6 +1189,35 @@ void cmGlobalGenerator::Configure()
("CMAKE_NUMBER_OF_MAKEFILES", num,
"number of local generators", cmState::INTERNAL);
+ {
+ std::ostringstream str;
+ str << this->GetCMakeInstance()->GetState()->DefinitionsSize();
+ this->GetCMakeInstance()->AddCacheEntry
+ ("CMAKE_NUMBER_OF_DEFINITION_STATES", str.str().c_str(),
+ "number of definition states", cmState::INTERNAL);
+ }
+ {
+ std::ostringstream str;
+ str << this->GetCMakeInstance()->GetState()->SnapshotsSize();
+ this->GetCMakeInstance()->AddCacheEntry
+ ("CMAKE_NUMBER_OF_SNAPSHOT_STATES", str.str().c_str(),
+ "number of snapshot states", cmState::INTERNAL);
+ }
+ {
+ std::ostringstream str;
+ str << this->GetCMakeInstance()->GetState()->ListFilesSize();
+ this->GetCMakeInstance()->AddCacheEntry
+ ("CMAKE_NUMBER_OF_LISTFILE_STATES", str.str().c_str(),
+ "number of listfile states", cmState::INTERNAL);
+ }
+ {
+ std::ostringstream str;
+ str << this->GetCMakeInstance()->GetState()->PoliciesSize();
+ this->GetCMakeInstance()->AddCacheEntry
+ ("CMAKE_NUMBER_OF_POLICY_STATES", str.str().c_str(),
+ "number of policy states", cmState::INTERNAL);
+ }
+
// check for link libraries and include directories containing "NOTFOUND"
// and for infinite loops
this->CheckLocalGenerators();
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index ab309ad..99a7537 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -651,6 +651,56 @@ bool cmState::UseMSYSShell() const
return this->MSYSShell;
}
+size_t cmState::DefinitionsSize() const
+{
+ return this->VarTree.Size();
+}
+
+void cmState::ReserveDefinitions(size_t amount)
+{
+ this->VarTree.Reserve(amount);
+}
+
+size_t cmState::SnapshotsSize() const
+{
+ return this->SnapshotData.Size();
+}
+
+void cmState::ReserveSnapshots(size_t amount)
+{
+ this->SnapshotData.Reserve(amount);
+}
+
+size_t cmState::ListFilesSize() const
+{
+ return this->ExecutionListFiles.Size();
+}
+
+void cmState::ReserveListFiles(size_t amount)
+{
+ this->ExecutionListFiles.Reserve(amount);
+}
+
+size_t cmState::DirectoriesSize() const
+{
+ return this->BuildsystemDirectory.Size();
+}
+
+void cmState::ReserveDirectories(size_t amount)
+{
+ this->BuildsystemDirectory.Reserve(amount);
+}
+
+size_t cmState::PoliciesSize() const
+{
+ return this->PolicyStack.Size();
+}
+
+void cmState::ReservePolicies(size_t amount)
+{
+ this->PolicyStack.Reserve(amount);
+}
+
const char* cmState::GetBinaryDirectory() const
{
return this->BinaryDirectory.c_str();
diff --git a/Source/cmState.h b/Source/cmState.h
index 5499665..8380587 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -270,6 +270,21 @@ public:
void SetMSYSShell(bool mSYSShell);
bool UseMSYSShell() const;
+ size_t DefinitionsSize() const;
+ void ReserveDefinitions(size_t amount);
+
+ size_t SnapshotsSize() const;
+ void ReserveSnapshots(size_t amount);
+
+ size_t ListFilesSize() const;
+ void ReserveListFiles(size_t amount);
+
+ size_t DirectoriesSize() const;
+ void ReserveDirectories(size_t amount);
+
+ size_t PoliciesSize() const;
+ void ReservePolicies(size_t amount);
+
private:
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
std::vector<std::string> EnabledLanguages;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d7fc7c3a403170035359e8e3b173725a04b6c1ff
commit d7fc7c3a403170035359e8e3b173725a04b6c1ff
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jun 21 13:04:43 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Aug 23 19:05:13 2015 +0200
cmLinkedTree: Add API for size query and reserve.
diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h
index 3bcb940..385dff2 100644
--- a/Source/cmLinkedTree.h
+++ b/Source/cmLinkedTree.h
@@ -161,6 +161,17 @@ public:
this->Data.clear();
}
+ size_t Size() const
+ {
+ return this->UpPositions.size();
+ }
+
+ void Reserve(size_t amount)
+ {
+ this->UpPositions.reserve(amount);
+ this->Data.reserve(amount);
+ }
+
private:
T& GetReference(PositionType pos)
{
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bff27391a91d1410ef33187c0c35acc0a709720d
commit bff27391a91d1410ef33187c0c35acc0a709720d
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jun 21 21:26:43 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Aug 23 19:05:11 2015 +0200
cmState: Host variable definitions.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1d02cfa..513a643 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -31,7 +31,6 @@
#endif
#include "cmInstallGenerator.h"
#include "cmTestGenerator.h"
-#include "cmDefinitions.h"
#include "cmAlgorithms.h"
#include "cmake.h"
#include <stdlib.h> // required for atoi
@@ -47,132 +46,7 @@
class cmMakefile::Internals
{
public:
-
- enum ScopeType
- {
- BaseScope,
- MacroScope,
- FunctionScope,
- VariableScope
- };
-
- struct VarScope
- {
- ScopeType Type;
- cmLinkedTree<cmDefinitions>::iterator Vars;
- cmLinkedTree<cmDefinitions>::iterator ParentScope;
- };
-
- cmLinkedTree<cmDefinitions> VarTree;
- cmLinkedTree<VarScope> VarScopes;
- cmLinkedTree<VarScope>::iterator VarScopeIter;
bool IsSourceFileTryCompile;
-
- void PushDefinitions(ScopeType scope)
- {
- assert(this->VarScopeIter.IsValid());
- assert(this->VarScopeIter->Vars.IsValid());
- cmLinkedTree<cmDefinitions>::iterator origin =
- this->VarScopeIter->Vars;
- cmLinkedTree<cmDefinitions>::iterator parentScope =
-// this->VarTree.Extend(origin);
- origin;
- this->VarScopeIter->Vars = parentScope;
- this->VarScopeIter = this->VarScopes.Extend(this->VarScopeIter);
- this->VarScopeIter->ParentScope = parentScope;
- this->VarScopeIter->Vars = this->VarTree.Extend(origin);
- this->VarScopeIter->Type = scope;
- }
-
- void InitializeVarScope()
- {
- assert(!this->VarScopeIter.IsValid());
- this->VarScopeIter = this->VarScopes.Extend(this->VarScopes.Root());
- this->VarScopeIter->Vars = this->VarTree.Extend(this->VarTree.Root());
- this->VarScopeIter->ParentScope = this->VarTree.Root();
- this->VarScopeIter->Type = BaseScope;
- }
-
- void InitializeDefinitions(cmMakefile* parent)
- {
- assert(this->VarScopeIter.IsValid());
- assert(this->VarScopeIter->Vars.IsValid());
- *this->VarScopeIter->Vars =
- cmDefinitions::MakeClosure(parent->Internal->VarScopeIter->Vars,
- parent->Internal->VarTree.Root());
- }
-
- const char* GetDefinition(std::string const& name)
- {
- assert(this->VarScopeIter.IsValid());
- assert(this->VarScopeIter->Vars.IsValid());
- return cmDefinitions::Get(name,
- this->VarScopeIter->Vars, this->VarTree.Root());
- }
-
- bool IsInitialized(std::string const& name)
- {
- return cmDefinitions::HasKey(name,
- this->VarScopeIter->Vars, this->VarTree.Root());
- }
-
- void SetDefinition(std::string const& name, std::string const& value)
- {
- this->VarScopeIter->Vars->Set(name, value.c_str());
- }
-
- void RemoveDefinition(std::string const& name)
- {
- this->VarScopeIter->Vars->Set(name, 0);
- }
-
- std::vector<std::string> UnusedKeys() const
- {
- return this->VarScopeIter->Vars->UnusedKeys();
- }
-
- std::vector<std::string> ClosureKeys() const
- {
- return cmDefinitions::ClosureKeys(this->VarScopeIter->Vars,
- this->VarTree.Root());
- }
-
- void PopDefinitions()
- {
- ++this->VarScopeIter;
- }
-
- bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
- {
- assert(this->VarScopeIter->Vars != this->VarTree.Root());
- if(this->VarScopeIter->ParentScope == this->VarTree.Root())
- {
- cmLocalGenerator* plg = mf->LocalGenerator->GetParent();
- if(!plg)
- {
- return false;
- }
- // 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);
- }
- return true;
- }
- // First localize the definition in the current scope.
- cmDefinitions::Raise(var, this->VarScopeIter->Vars, this->VarTree.Root());
-
- // Now update the definition in the parent scope.
- this->VarScopeIter->ParentScope->Set(var, varDef);
- return true;
- }
};
// default is not to be building executables
@@ -181,7 +55,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
LocalGenerator(localGenerator),
StateSnapshot(localGenerator->GetStateSnapshot())
{
- this->Internal->InitializeVarScope();
this->Internal->IsSourceFileTryCompile = false;
// Initialize these first since AddDefaultDefinitions calls AddDefinition
@@ -1607,9 +1480,6 @@ void cmMakefile::AddLinkLibrary(const std::string& lib)
void cmMakefile::InitializeFromParent(cmMakefile* parent)
{
- // Initialize definitions with the closure of the parent scope.
- this->Internal->InitializeDefinitions(parent);
-
this->StateSnapshot.InitializeFromParent();
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
@@ -1674,8 +1544,6 @@ void cmMakefile::PushFunctionScope(std::string const& fileName,
fileName);
assert(this->StateSnapshot.IsValid());
- this->Internal->PushDefinitions(Internals::FunctionScope);
-
this->PushLoopBlockBarrier();
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -1702,8 +1570,6 @@ void cmMakefile::PopFunctionScope(bool reportError)
this->PopLoopBlockBarrier();
this->CheckForUnusedVariables();
-
- this->Internal->PopDefinitions();
}
void cmMakefile::PushMacroScope(std::string const& fileName,
@@ -2007,7 +1873,7 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value)
{
this->LogUnused("changing definition", name);
}
- this->Internal->SetDefinition(name, value);
+ this->StateSnapshot.SetDefinition(name, value);
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
@@ -2070,7 +1936,7 @@ 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->RemoveDefinition(name);
+ this->StateSnapshot.RemoveDefinition(name);
}
@@ -2080,7 +1946,9 @@ void cmMakefile::AddDefinition(const std::string& name, bool value)
{
this->LogUnused("changing definition", name);
}
- this->Internal->SetDefinition(name, value ? "ON" : "OFF");
+
+ this->StateSnapshot.SetDefinition(name, value ? "ON" : "OFF");
+
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
if ( vv )
@@ -2097,7 +1965,7 @@ void cmMakefile::CheckForUnusedVariables() const
{
return;
}
- const std::vector<std::string>& unused = this->Internal->UnusedKeys();
+ const std::vector<std::string>& unused = this->StateSnapshot.UnusedKeys();
std::vector<std::string>::const_iterator it = unused.begin();
for (; it != unused.end(); ++it)
{
@@ -2107,12 +1975,12 @@ void cmMakefile::CheckForUnusedVariables() const
void cmMakefile::MarkVariableAsUsed(const std::string& var)
{
- this->Internal->GetDefinition(var);
+ this->StateSnapshot.GetDefinition(var);
}
bool cmMakefile::VariableInitialized(const std::string& var) const
{
- return this->Internal->IsInitialized(var);
+ return this->StateSnapshot.IsInitialized(var);
}
void cmMakefile::LogUnused(const char* reason,
@@ -2160,7 +2028,7 @@ void cmMakefile::RemoveDefinition(const std::string& name)
{
this->LogUnused("unsetting", name);
}
- this->Internal->RemoveDefinition(name);
+ this->StateSnapshot.RemoveDefinition(name);
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
if ( vv )
@@ -2626,7 +2494,7 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
bool cmMakefile::IsDefinitionSet(const std::string& name) const
{
- const char* def = this->Internal->GetDefinition(name);
+ const char* def = this->StateSnapshot.GetDefinition(name);
if(!def)
{
def = this->GetState()->GetInitializedCacheValue(name);
@@ -2647,7 +2515,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
const char* cmMakefile::GetDefinition(const std::string& name) const
{
- const char* def = this->Internal->GetDefinition(name);
+ const char* def = this->StateSnapshot.GetDefinition(name);
if(!def)
{
def = this->GetState()->GetInitializedCacheValue(name);
@@ -2683,7 +2551,7 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const
std::vector<std::string> cmMakefile::GetDefinitions() const
{
- std::vector<std::string> res = this->Internal->ClosureKeys();
+ std::vector<std::string> res = this->StateSnapshot.ClosureKeys();
std::vector<std::string> cacheKeys = this->GetState()->GetCacheEntryKeys();
res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
std::sort(res.begin(), res.end());
@@ -4462,8 +4330,6 @@ std::string cmMakefile::FormatListFileStack() const
void cmMakefile::PushScope()
{
- this->Internal->PushDefinitions(Internals::VariableScope);
-
std::string commandName;
long line = 0;
if (!this->ContextStack.empty())
@@ -4492,7 +4358,6 @@ void cmMakefile::PopScope()
this->CheckForUnusedVariables();
- this->Internal->PopDefinitions();
this->StateSnapshot =
this->GetState()->Pop(this->StateSnapshot);
assert(this->StateSnapshot.IsValid());
@@ -4505,7 +4370,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
return;
}
- if (!this->Internal->RaiseScope(var, varDef, this))
+ if (!this->StateSnapshot.RaiseScope(var, varDef))
{
std::ostringstream m;
m << "Cannot set \"" << var << "\": current scope has no parent.";
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 9e09353..ab309ad 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -15,6 +15,7 @@
#include "cmCacheManager.h"
#include "cmCommand.h"
#include "cmAlgorithms.h"
+#include "cmDefinitions.h"
#include <assert.h>
@@ -29,6 +30,9 @@ struct cmState::SnapshotDataType
cmLinkedTree<std::string>::iterator ExecutionListFile;
cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator
BuildSystemDirectory;
+ cmLinkedTree<cmDefinitions>::iterator Vars;
+ cmLinkedTree<cmDefinitions>::iterator Root;
+ cmLinkedTree<cmDefinitions>::iterator Parent;
std::string EntryPointCommand;
long EntryPointLine;
std::vector<std::string>::size_type IncludeDirectoryPosition;
@@ -275,6 +279,10 @@ cmState::Snapshot cmState::Reset()
pos->PolicyScope = this->PolicyStack.Root();
assert(pos->Policies.IsValid());
assert(pos->PolicyRoot.IsValid());
+ this->VarTree.Clear();
+ pos->Vars = this->VarTree.Extend(this->VarTree.Root());
+ pos->Parent = this->VarTree.Root();
+ pos->Root = this->VarTree.Root();
this->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
@@ -752,6 +760,10 @@ cmState::Snapshot cmState::CreateBaseSnapshot()
pos->PolicyScope = this->PolicyStack.Root();
assert(pos->Policies.IsValid());
assert(pos->PolicyRoot.IsValid());
+ pos->Vars = this->VarTree.Extend(this->VarTree.Root());
+ assert(pos->Vars.IsValid());
+ pos->Parent = this->VarTree.Root();
+ pos->Root = this->VarTree.Root();
return cmState::Snapshot(this, pos);
}
@@ -779,6 +791,12 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
pos->PolicyScope = originSnapshot.Position->Policies;
assert(pos->Policies.IsValid());
assert(pos->PolicyRoot.IsValid());
+
+ cmLinkedTree<cmDefinitions>::iterator origin =
+ originSnapshot.Position->Vars;
+ pos->Parent = origin;
+ pos->Root = origin;
+ pos->Vars = this->VarTree.Extend(origin);
return cmState::Snapshot(this, pos);
}
@@ -798,6 +816,11 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot,
originSnapshot.Position->ExecutionListFile, fileName);
pos->BuildSystemDirectory->DirectoryEnd = pos;
pos->PolicyScope = originSnapshot.Position->Policies;
+ assert(originSnapshot.Position->Vars.IsValid());
+ cmLinkedTree<cmDefinitions>::iterator origin =
+ originSnapshot.Position->Vars;
+ pos->Parent = origin;
+ pos->Vars = this->VarTree.Extend(origin);
return cmState::Snapshot(this, pos);
}
@@ -815,6 +838,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot,
pos->SnapshotType = MacroCallType;
pos->ExecutionListFile = this->ExecutionListFiles.Extend(
originSnapshot.Position->ExecutionListFile, fileName);
+ assert(originSnapshot.Position->Vars.IsValid());
pos->BuildSystemDirectory->DirectoryEnd = pos;
pos->PolicyScope = originSnapshot.Position->Policies;
return cmState::Snapshot(this, pos);
@@ -833,6 +857,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot,
pos->SnapshotType = CallStackType;
pos->ExecutionListFile = this->ExecutionListFiles.Extend(
originSnapshot.Position->ExecutionListFile, fileName);
+ assert(originSnapshot.Position->Vars.IsValid());
pos->BuildSystemDirectory->DirectoryEnd = pos;
pos->PolicyScope = originSnapshot.Position->Policies;
return cmState::Snapshot(this, pos);
@@ -849,7 +874,13 @@ cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot,
pos->EntryPointLine = entryPointLine;
pos->EntryPointCommand = entryPointCommand;
pos->SnapshotType = VariableScopeType;
+ assert(originSnapshot.Position->Vars.IsValid());
+ cmLinkedTree<cmDefinitions>::iterator origin =
+ originSnapshot.Position->Vars;
+ pos->Parent = origin;
+ pos->Vars = this->VarTree.Extend(origin);
+ assert(pos->Vars.IsValid());
return cmState::Snapshot(this, pos);
}
@@ -1141,6 +1172,72 @@ bool cmState::Snapshot::HasDefinedPolicyCMP0011()
return !this->Position->Policies->IsEmpty();
}
+const char* cmState::Snapshot::GetDefinition(std::string const& name) const
+{
+ assert(this->Position->Vars.IsValid());
+ return cmDefinitions::Get(name, this->Position->Vars,
+ this->Position->Root);
+}
+
+bool cmState::Snapshot::IsInitialized(std::string const& name) const
+{
+ return cmDefinitions::HasKey(name, this->Position->Vars,
+ this->Position->Root);
+}
+
+void cmState::Snapshot::SetDefinition(std::string const& name,
+ std::string const& value)
+{
+ this->Position->Vars->Set(name, value.c_str());
+}
+
+void cmState::Snapshot::RemoveDefinition(std::string const& name)
+{
+ this->Position->Vars->Set(name, 0);
+}
+
+std::vector<std::string> cmState::Snapshot::UnusedKeys() const
+{
+ return this->Position->Vars->UnusedKeys();
+}
+
+std::vector<std::string> cmState::Snapshot::ClosureKeys() const
+{
+ return cmDefinitions::ClosureKeys(this->Position->Vars,
+ this->Position->Root);
+}
+
+bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef)
+{
+ if(this->Position->ScopeParent == this->Position->DirectoryParent)
+ {
+ Snapshot parentDir = this->GetBuildsystemDirectoryParent();
+ if(!parentDir.IsValid())
+ {
+ return false;
+ }
+ // 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.
+ if (varDef)
+ {
+ parentDir.SetDefinition(var, varDef);
+ }
+ else
+ {
+ parentDir.RemoveDefinition(var);
+ }
+ return true;
+ }
+ // First localize the definition in the current scope.
+ cmDefinitions::Raise(var, this->Position->Vars,
+ this->Position->Root);
+
+ // Now update the definition in the parent scope.
+ this->Position->Parent->Set(var, varDef);
+ return true;
+}
+
static const std::string cmPropertySentinal = std::string();
template<typename T, typename U, typename V>
@@ -1177,6 +1274,11 @@ void InitializeContentFromParent(T& parentContent,
void cmState::Snapshot::InitializeFromParent()
{
PositionType parent = this->Position->DirectoryParent;
+ assert(this->Position->Vars.IsValid());
+ assert(parent->Vars.IsValid());
+
+ *this->Position->Vars =
+ cmDefinitions::MakeClosure(parent->Vars, parent->Root);
InitializeContentFromParent(parent->BuildSystemDirectory->IncludeDirectories,
this->Position->BuildSystemDirectory->IncludeDirectories,
diff --git a/Source/cmState.h b/Source/cmState.h
index 4d87653..5499665 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -21,6 +21,8 @@
class cmake;
class cmCommand;
+class cmDefinitions;
+class cmListFileBacktrace;
class cmState
{
@@ -52,6 +54,14 @@ public:
Snapshot(cmState* state = 0);
Snapshot(cmState* state, PositionType position);
+ const char* GetDefinition(std::string const& name) const;
+ bool IsInitialized(std::string const& name) const;
+ void SetDefinition(std::string const& name, std::string const& value);
+ void RemoveDefinition(std::string const& name);
+ std::vector<std::string> UnusedKeys() const;
+ std::vector<std::string> ClosureKeys() const;
+ bool RaiseScope(std::string const& var, const char* varDef);
+
void SetListFile(std::string const& listfile);
std::string GetExecutionListFile() const;
@@ -273,6 +283,7 @@ private:
cmLinkedTree<PolicyStackEntry> PolicyStack;
cmLinkedTree<SnapshotDataType> SnapshotData;
+ cmLinkedTree<cmDefinitions> VarTree;
std::vector<std::string> SourceDirectoryComponents;
std::vector<std::string> BinaryDirectoryComponents;
-----------------------------------------------------------------------
Summary of changes:
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list