diff options
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r-- | Source/cmState.cxx | 171 |
1 files changed, 156 insertions, 15 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx index d8f8306..f425861 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -20,8 +20,10 @@ struct cmState::SnapshotDataType { - cmState::PositionType CallStackParent; cmState::PositionType DirectoryParent; + cmLinkedTree<cmState::PolicyStackEntry>::iterator Policies; + cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyRoot; + cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyScope; cmState::SnapshotType SnapshotType; cmLinkedTree<std::string>::iterator ExecutionListFile; cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator @@ -33,8 +35,19 @@ struct cmState::SnapshotDataType std::vector<std::string>::size_type CompileOptionsPosition; }; +struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap +{ + typedef cmPolicies::PolicyMap derived; + PolicyStackEntry(bool w = false): derived(), Weak(w) {} + PolicyStackEntry(derived const& d, bool w): derived(d), Weak(w) {} + PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} + bool Weak; +}; + struct cmState::BuildsystemDirectoryStateType { + cmState::PositionType DirectoryEnd; + std::string Location; std::string OutputLocation; @@ -240,6 +253,9 @@ cmState::Snapshot cmState::Reset() this->GlobalProperties.clear(); this->PropertyDefinitions.clear(); + PositionType pos = this->SnapshotData.Truncate(); + this->ExecutionListFiles.Truncate(); + { cmLinkedTree<BuildsystemDirectoryStateType>::iterator it = this->BuildsystemDirectory.Truncate(); @@ -249,9 +265,15 @@ cmState::Snapshot cmState::Reset() it->CompileDefinitionsBacktraces.clear(); it->CompileOptions.clear(); it->CompileOptionsBacktraces.clear(); + it->DirectoryEnd = pos; } - PositionType pos = this->SnapshotData.Truncate(); - this->ExecutionListFiles.Truncate(); + + this->PolicyStack.Clear(); + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -722,6 +744,12 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->IncludeDirectoryPosition = 0; pos->CompileDefinitionsPosition = 0; pos->CompileOptionsPosition = 0; + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -732,7 +760,6 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, { assert(originSnapshot.IsValid()); PositionType pos = this->SnapshotData.Extend(originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; @@ -743,6 +770,12 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = originSnapshot.Position->Policies; + pos->PolicyRoot = originSnapshot.Position->Policies; + pos->PolicyScope = originSnapshot.Position->Policies; + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -754,12 +787,13 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = FunctionCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -772,12 +806,13 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = MacroCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -789,12 +824,13 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = CallStackType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -806,12 +842,24 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = InlineListFileType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; + return cmState::Snapshot(this, pos); +} + +cmState::Snapshot +cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->SnapshotType = PolicyScopeType; + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -826,12 +874,9 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) prevPos->BuildSystemDirectory->CompileDefinitions.size(); prevPos->CompileOptionsPosition = prevPos->BuildSystemDirectory->CompileOptions.size(); + prevPos->BuildSystemDirectory->DirectoryEnd = prevPos; - if (prevPos == this->SnapshotData.Root()) - { - return Snapshot(this, prevPos); - } - return Snapshot(this, originSnapshot.Position->CallStackParent); + return Snapshot(this, prevPos); } cmState::Snapshot::Snapshot(cmState* state) @@ -847,6 +892,11 @@ cmState::Snapshot::Snapshot(cmState* state, PositionType position) } +cmState::SnapshotType cmState::Snapshot::GetType() const +{ + return this->Position->SnapshotType; +} + const char* cmState::Directory::GetCurrentSource() const { return this->DirectoryState->Location.c_str(); @@ -964,13 +1014,22 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const assert(this->Position != this->State->SnapshotData.Root()); Snapshot snapshot; - if (this->Position->SnapshotType == cmState::BuildsystemDirectoryType) + PositionType parentPos = this->Position; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType) { return snapshot; } - PositionType parentPos = this->Position; ++parentPos; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos == this->State->SnapshotData.Root()) { return snapshot; @@ -980,6 +1039,88 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const return snapshot; } +void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak) +{ + PositionType pos = this->Position; + pos->Policies = + this->State->PolicyStack.Extend(pos->Policies, + PolicyStackEntry(entry, weak)); +} + +bool cmState::Snapshot::PopPolicy() +{ + PositionType pos = this->Position; + if (pos->Policies == pos->PolicyScope) + { + return false; + } + ++pos->Policies; + return true; +} + +bool cmState::Snapshot::CanPopPolicyScope() +{ + return this->Position->Policies == this->Position->PolicyScope; +} + +void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id, + cmPolicies::PolicyStatus status) +{ + // Update the policy stack from the top to the top-most strong entry. + bool previous_was_weak = true; + for(cmLinkedTree<PolicyStackEntry>::iterator psi = this->Position->Policies; + previous_was_weak && psi != this->Position->PolicyRoot; ++psi) + { + psi->Set(id, status); + previous_was_weak = psi->Weak; + } +} + +cmPolicies::PolicyStatus +cmState::Snapshot::GetPolicy(cmPolicies::PolicyID id) const +{ + cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); + + if(status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) + { + return status; + } + + cmLinkedTree<BuildsystemDirectoryStateType>::iterator dir = + this->Position->BuildSystemDirectory; + + while (true) + { + assert(dir.IsValid()); + cmLinkedTree<PolicyStackEntry>::iterator leaf = + dir->DirectoryEnd->Policies; + cmLinkedTree<PolicyStackEntry>::iterator root = + dir->DirectoryEnd->PolicyRoot; + for( ; leaf != root; ++leaf) + { + if(leaf->IsDefined(id)) + { + status = leaf->Get(id); + return status; + } + } + cmState::PositionType e = dir->DirectoryEnd; + cmState::PositionType p = e->DirectoryParent; + if (p == this->State->SnapshotData.Root()) + { + break; + } + dir = p->BuildSystemDirectory; + } + return status; +} + +bool cmState::Snapshot::HasDefinedPolicyCMP0011() +{ + return !this->Position->Policies->IsEmpty(); +} + static const std::string cmPropertySentinal = std::string(); template<typename T, typename U, typename V> |