cmState: Store execution context.
Extend snapshot creation API to store the file being executed and the entry point to get to that context.
This commit is contained in:
parent
94704d759c
commit
6361f68056
|
@ -95,6 +95,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass
|
|||
}
|
||||
|
||||
cmMakefile::FunctionPushPop functionScope(this->Makefile,
|
||||
this->FilePath,
|
||||
this->Policies);
|
||||
|
||||
// set the value of argc
|
||||
|
|
|
@ -97,6 +97,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
|||
}
|
||||
|
||||
cmMakefile::MacroPushPop macroScope(this->Makefile,
|
||||
this->FilePath,
|
||||
this->Policies);
|
||||
|
||||
// set the value of argc
|
||||
|
|
|
@ -466,7 +466,10 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
|
|||
|
||||
this->Makefile->StateSnapshot =
|
||||
this->Makefile->GetState()->CreateCallStackSnapshot(
|
||||
this->Makefile->StateSnapshot);
|
||||
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()
|
||||
|
|
|
@ -720,7 +720,7 @@ public:
|
|||
class FunctionPushPop
|
||||
{
|
||||
public:
|
||||
FunctionPushPop(cmMakefile* mf,
|
||||
FunctionPushPop(cmMakefile* mf, std::string const& fileName,
|
||||
cmPolicies::PolicyMap const& pm);
|
||||
~FunctionPushPop();
|
||||
|
||||
|
@ -733,7 +733,7 @@ public:
|
|||
class MacroPushPop
|
||||
{
|
||||
public:
|
||||
MacroPushPop(cmMakefile* mf,
|
||||
MacroPushPop(cmMakefile* mf, std::string const& fileName,
|
||||
cmPolicies::PolicyMap const& pm);
|
||||
~MacroPushPop();
|
||||
|
||||
|
@ -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();
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue