cmState: Add Type for policy scope.

This commit is contained in:
Stephen Kelly 2015-07-26 12:56:10 +02:00
parent af0de01c6b
commit 348354333a
3 changed files with 34 additions and 3 deletions

View File

@ -189,6 +189,9 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)");
this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{");
this->StateSnapshot = this->StateSnapshot.GetState()
->CreatePolicyScopeSnapshot(this->StateSnapshot);
// Protect the directory-level policies.
this->PushPolicyBarrier();
@ -1705,6 +1708,8 @@ public:
this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource();
currentStart += "/CMakeLists.txt";
this->Makefile->StateSnapshot.SetListFile(currentStart);
this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot);
this->Makefile->PushPolicyBarrier();
this->Makefile->PushFunctionBlockerBarrier();
@ -1722,6 +1727,8 @@ public:
{
this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
this->Makefile->PopPolicyBarrier(this->ReportError);
this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
->Pop(this->Makefile->StateSnapshot);
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->GG->GetFileLockPool().PopFileScope();
#endif
@ -4841,6 +4848,8 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak,
cmPolicies::PolicyMap const& pm):
Makefile(m), ReportError(true)
{
this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot);
this->Makefile->PushPolicyBarrier();
this->Makefile->PushPolicy(weak, pm);
}
@ -4850,6 +4859,8 @@ cmMakefile::PolicyPushPop::~PolicyPushPop()
{
this->Makefile->PopPolicy();
this->Makefile->PopPolicyBarrier(this->ReportError);
this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
->Pop(this->Makefile->StateSnapshot);
}
//----------------------------------------------------------------------------

View File

@ -809,6 +809,15 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot,
return cmState::Snapshot(this, pos);
}
cmState::Snapshot
cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot)
{
PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
*originSnapshot.Position);
pos->SnapshotType = PolicyScopeType;
return cmState::Snapshot(this, pos);
}
cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
{
PositionType pos = originSnapshot.Position;
@ -959,13 +968,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;

View File

@ -37,7 +37,8 @@ public:
FunctionCallType,
MacroCallType,
CallStackType,
InlineListFileType
InlineListFileType,
PolicyScopeType
};
class Directory;
@ -148,6 +149,7 @@ public:
const std::string& entryPointCommand,
long entryPointLine,
std::string const& fileName);
Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot);
Snapshot Pop(Snapshot originSnapshot);
enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC,