From 3a041c59495df26c2b7b0ee58069d27a03bd18ff Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 11 Apr 2015 18:38:16 +0200 Subject: Introduce cmState::Snapshot. Create snapshots for buildsystem directories during configure time. This class will be extended in follow up commits to snapshot all values in the cmState. --- Source/cmMakefile.cxx | 18 +++++++++++++++++- Source/cmMakefile.h | 2 +- Source/cmState.cxx | 15 +++++++++++++++ Source/cmState.h | 15 +++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8c6b195..5d48f58 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -54,7 +54,10 @@ public: // default is not to be building executables cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) - : Internal(new Internals) + : Internal(new Internals), + LocalGenerator(localGenerator), + StateSnapshot(localGenerator->GetGlobalGenerator() + ->GetCMakeInstance()->GetState()) { const cmDefinitions& defs = cmDefinitions(); const std::set globalKeys = defs.LocalKeys(); @@ -63,6 +66,19 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->Internal->VarUsageStack.push(globalKeys); 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; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index d120fb3..447dadc 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -922,7 +922,7 @@ private: cmMakefile& operator=(const cmMakefile& mf); void Initialize(); - + cmState::Snapshot StateSnapshot; bool ReadListFileInternal(const char* filenametoread, bool noPolicyScope, diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 6fbbc4b..610257e 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -22,6 +22,7 @@ cmState::cmState(cmake* cm) : CMakeInstance(cm), IsInTryCompile(false) { + this->CreateSnapshot(Snapshot()); this->Initialize(); } @@ -466,3 +467,17 @@ const char* cmState::GetBinaryDirectory() const { return this->BinaryDirectory.c_str(); } + +cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot) +{ + PositionType pos = this->ParentPositions.size(); + this->ParentPositions.push_back(originSnapshot.Position); + return cmState::Snapshot(this, pos); +} + +cmState::Snapshot::Snapshot(cmState* state, PositionType position) + : State(state), + Position(position) +{ + +} diff --git a/Source/cmState.h b/Source/cmState.h index afacc36..f35cbd6 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -21,10 +21,24 @@ class cmCommand; class cmState { + typedef std::vector::size_type PositionType; + friend class Snapshot; public: cmState(cmake* cm); ~cmState(); + class Snapshot { + public: + Snapshot(cmState* state = 0, PositionType position = 0); + + private: + friend class cmState; + cmState* State; + cmState::PositionType Position; + }; + + Snapshot CreateSnapshot(Snapshot originSnapshot); + enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, UNINITIALIZED }; static CacheEntryType StringToCacheEntryType(const char*); @@ -106,6 +120,7 @@ private: std::map Commands; cmPropertyMap GlobalProperties; cmake* CMakeInstance; + std::vector ParentPositions; std::string SourceDirectory; std::string BinaryDirectory; bool IsInTryCompile; -- cgit v0.12