summaryrefslogtreecommitdiffstats
path: root/Source/cmState.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-06-21 19:26:43 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-08-23 17:05:11 (GMT)
commitbff27391a91d1410ef33187c0c35acc0a709720d (patch)
tree762c440fea8eca1b8d9b848bd0aefe0bd294e0a2 /Source/cmState.cxx
parent6954c8936f52dcf7710e4b72b2e090b79bf38d1c (diff)
downloadCMake-bff27391a91d1410ef33187c0c35acc0a709720d.zip
CMake-bff27391a91d1410ef33187c0c35acc0a709720d.tar.gz
CMake-bff27391a91d1410ef33187c0c35acc0a709720d.tar.bz2
cmState: Host variable definitions.
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r--Source/cmState.cxx102
1 files changed, 102 insertions, 0 deletions
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,