diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-05-31 17:37:08 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-07-05 23:37:15 (GMT) |
commit | 6361f680568c81e0391fa56cf9a7f4637bd745dc (patch) | |
tree | 24e8c14c2bf179a931ea9d1baa44f5ead864b419 | |
parent | 94704d759cc8939f3573122d36d52c4598fd04ba (diff) | |
download | CMake-6361f680568c81e0391fa56cf9a7f4637bd745dc.zip CMake-6361f680568c81e0391fa56cf9a7f4637bd745dc.tar.gz CMake-6361f680568c81e0391fa56cf9a7f4637bd745dc.tar.bz2 |
cmState: Store execution context.
Extend snapshot creation API to store the file being executed and the
entry point to get to that context.
-rw-r--r-- | Source/cmFunctionCommand.cxx | 1 | ||||
-rw-r--r-- | Source/cmMacroCommand.cxx | 1 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 41 | ||||
-rw-r--r-- | Source/cmMakefile.h | 12 | ||||
-rw-r--r-- | Source/cmState.cxx | 71 | ||||
-rw-r--r-- | Source/cmState.h | 32 |
6 files changed, 133 insertions, 25 deletions
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index b3576c3..78853ce 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -95,6 +95,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass } cmMakefile::FunctionPushPop functionScope(this->Makefile, + this->FilePath, this->Policies); // set the value of argc diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 0b945b2..3c2117b 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -97,6 +97,7 @@ bool cmMacroHelperCommand::InvokeInitialPass } cmMakefile::MacroPushPop macroScope(this->Makefile, + this->FilePath, this->Policies); // set the value of argc diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a176cda..eb26474 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -465,8 +465,11 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, this->Makefile->PushFunctionBlockerBarrier(); this->Makefile->StateSnapshot = - this->Makefile->GetState()->CreateCallStackSnapshot( - this->Makefile->StateSnapshot); + this->Makefile->GetState()->CreateCallStackSnapshot( + this->Makefile->StateSnapshot, + this->Makefile->ContextStack.back()->Name, + this->Makefile->ContextStack.back()->Line, + filenametoread); } //---------------------------------------------------------------------------- @@ -576,9 +579,16 @@ public: this->Makefile->ListFileStack.push_back(filenametoread); this->Makefile->PushPolicyBarrier(); + long line = 0; + std::string name; + if (!this->Makefile->ContextStack.empty()) + { + line = this->Makefile->ContextStack.back()->Line; + name = this->Makefile->ContextStack.back()->Name; + } this->Makefile->StateSnapshot = this->Makefile->GetState()->CreateInlineListFileSnapshot( - this->Makefile->StateSnapshot); + this->Makefile->StateSnapshot, name, line, filenametoread); assert(this->Makefile->StateSnapshot.IsValid()); this->Makefile->PushFunctionBlockerBarrier(); } @@ -1590,11 +1600,14 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) this->ImportedTargets = parent->ImportedTargets; } -void cmMakefile::PushFunctionScope(const cmPolicies::PolicyMap& pm) +void cmMakefile::PushFunctionScope(std::string const& fileName, + const cmPolicies::PolicyMap& pm) { this->StateSnapshot = this->GetState()->CreateFunctionCallSnapshot( - this->StateSnapshot); + this->StateSnapshot, + this->ContextStack.back()->Name, this->ContextStack.back()->Line, + fileName); assert(this->StateSnapshot.IsValid()); this->Internal->PushDefinitions(); @@ -1632,11 +1645,14 @@ void cmMakefile::PopFunctionScope(bool reportError) this->Internal->PopDefinitions(); } -void cmMakefile::PushMacroScope(const cmPolicies::PolicyMap& pm) +void cmMakefile::PushMacroScope(std::string const& fileName, + const cmPolicies::PolicyMap& pm) { this->StateSnapshot = this->GetState()->CreateMacroCallSnapshot( - this->StateSnapshot); + this->StateSnapshot, + this->ContextStack.back()->Name, this->ContextStack.back()->Line, + fileName); assert(this->StateSnapshot.IsValid()); this->PushFunctionBlockerBarrier(); @@ -1670,6 +1686,7 @@ public: std::string currentStart = this->Makefile->StateSnapshot.GetCurrentSourceDirectory(); currentStart += "/CMakeLists.txt"; + this->Makefile->StateSnapshot.SetListFile(currentStart); this->Makefile->ListFileStack.push_back(currentStart); this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); @@ -1813,7 +1830,9 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, } cmState::Snapshot newSnapshot = this->GetState() - ->CreateBuildsystemDirectorySnapshot(this->StateSnapshot); + ->CreateBuildsystemDirectorySnapshot(this->StateSnapshot, + this->ContextStack.back()->Name, + this->ContextStack.back()->Line); // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() @@ -5511,10 +5530,11 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf, + const std::string& fileName, cmPolicies::PolicyMap const& pm) : Makefile(mf), ReportError(true) { - this->Makefile->PushFunctionScope(pm); + this->Makefile->PushFunctionScope(fileName, pm); } cmMakefile::FunctionPushPop::~FunctionPushPop() @@ -5524,10 +5544,11 @@ cmMakefile::FunctionPushPop::~FunctionPushPop() cmMakefile::MacroPushPop::MacroPushPop(cmMakefile* mf, + const std::string& fileName, const cmPolicies::PolicyMap& pm) : Makefile(mf), ReportError(true) { - this->Makefile->PushMacroScope(pm); + this->Makefile->PushMacroScope(fileName, pm); } cmMakefile::MacroPushPop::~MacroPushPop() diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 0ade8e1..01c9e8c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -720,7 +720,7 @@ public: class FunctionPushPop { public: - FunctionPushPop(cmMakefile* mf, + FunctionPushPop(cmMakefile* mf, std::string const& fileName, cmPolicies::PolicyMap const& pm); ~FunctionPushPop(); @@ -733,8 +733,8 @@ public: class MacroPushPop { public: - MacroPushPop(cmMakefile* mf, - cmPolicies::PolicyMap const& pm); + MacroPushPop(cmMakefile* mf, std::string const& fileName, + cmPolicies::PolicyMap const& pm); ~MacroPushPop(); void Quiet() { this->ReportError = false; } @@ -743,9 +743,11 @@ public: bool ReportError; }; - void PushFunctionScope(cmPolicies::PolicyMap const& pm); + void PushFunctionScope(std::string const& fileName, + cmPolicies::PolicyMap const& pm); void PopFunctionScope(bool reportError); - void PushMacroScope(cmPolicies::PolicyMap const& pm); + void PushMacroScope(std::string const& fileName, + cmPolicies::PolicyMap const& pm); void PopMacroScope(bool reportError); void PushScope(); void PopScope(); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 5ca1cce..d918f65 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -23,8 +23,11 @@ struct cmState::SnapshotDataType cmState::PositionType CallStackParent; cmState::PositionType DirectoryParent; cmState::SnapshotType SnapshotType; + cmLinkedTree<std::string>::iterator ExecutionListFile; cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator BuildSystemDirectory; + std::string EntryPointCommand; + long EntryPointLine; }; struct cmState::BuildsystemDirectoryStateType @@ -227,6 +230,7 @@ cmState::Snapshot cmState::Reset() this->BuildsystemDirectory.Truncate(); PositionType pos = this->SnapshotData.Truncate(); + this->ExecutionListFiles.Truncate(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -683,61 +687,98 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->SnapshotType = BuildsystemDirectoryType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root()); + pos->ExecutionListFile = + this->ExecutionListFiles.Extend(this->ExecutionListFiles.Root()); return cmState::Snapshot(this, pos); } cmState::Snapshot -cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot) +cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine) { assert(originSnapshot.IsValid()); PositionType pos = this->SnapshotData.Extend(originSnapshot.Position); pos->CallStackParent = originSnapshot.Position; + pos->EntryPointLine = entryPointLine; + pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; pos->SnapshotType = BuildsystemDirectoryType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend( originSnapshot.Position->BuildSystemDirectory); + pos->ExecutionListFile = + this->ExecutionListFiles.Extend( + originSnapshot.Position->ExecutionListFile); return cmState::Snapshot(this, pos); } cmState::Snapshot -cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot) +cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName) { 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); return cmState::Snapshot(this, pos); } cmState::Snapshot -cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot) +cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName) { 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); return cmState::Snapshot(this, pos); } cmState::Snapshot -cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot) +cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, + const std::string& entryPointCommand, + long entryPointLine, + const std::string& fileName) { 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); return cmState::Snapshot(this, pos); } cmState::Snapshot -cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot) +cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, + const std::string& entryPointCommand, + long entryPointLine, + const std::string& fileName) { 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); return cmState::Snapshot(this, pos); } @@ -797,6 +838,11 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir) this->ComputeRelativePathTopBinary(); } +void cmState::Snapshot::SetListFile(const std::string& listfile) +{ + *this->Position->ExecutionListFile = listfile; +} + std::vector<std::string> const& cmState::Snapshot::GetCurrentSourceDirectoryComponents() const { @@ -831,6 +877,21 @@ void cmState::Snapshot::SetRelativePathTopBinary(const char* dir) this->Position->BuildSystemDirectory->RelativePathTopBinary = dir; } +std::string cmState::Snapshot::GetExecutionListFile() const +{ + return *this->Position->ExecutionListFile; +} + +std::string cmState::Snapshot::GetEntryPointCommand() const +{ + return this->Position->EntryPointCommand; +} + +long cmState::Snapshot::GetEntryPointLine() const +{ + return this->Position->EntryPointLine; +} + bool cmState::Snapshot::IsValid() const { return this->State && this->Position.IsValid() diff --git a/Source/cmState.h b/Source/cmState.h index e35b843..473a194 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -47,6 +47,8 @@ public: const char* GetCurrentBinaryDirectory() const; void SetCurrentBinaryDirectory(std::string const& dir); + void SetListFile(std::string const& listfile); + std::vector<std::string> const& GetCurrentSourceDirectoryComponents() const; std::vector<std::string> const& @@ -57,6 +59,10 @@ public: void SetRelativePathTopSource(const char* dir); void SetRelativePathTopBinary(const char* dir); + std::string GetExecutionListFile() const; + std::string GetEntryPointCommand() const; + long GetEntryPointLine() const; + bool IsValid() const; Snapshot GetBuildsystemDirectoryParent() const; Snapshot GetCallStackParent() const; @@ -75,11 +81,25 @@ public: Snapshot CreateBaseSnapshot(); Snapshot - CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot); - Snapshot CreateFunctionCallSnapshot(Snapshot originSnapshot); - Snapshot CreateMacroCallSnapshot(Snapshot originSnapshot); - Snapshot CreateCallStackSnapshot(Snapshot originSnapshot); - Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot); + CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine); + Snapshot CreateFunctionCallSnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName); + Snapshot CreateMacroCallSnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName); + Snapshot CreateCallStackSnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName); + Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot, + const std::string& entryPointCommand, + long entryPointLine, + std::string const& fileName); Snapshot Pop(Snapshot originSnapshot); enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, @@ -186,6 +206,8 @@ private: struct BuildsystemDirectoryStateType; cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory; + cmLinkedTree<std::string> ExecutionListFiles; + cmLinkedTree<SnapshotDataType> SnapshotData; std::vector<std::string> SourceDirectoryComponents; |