cmMakefile: return a backtrace

This allows backtraces to be fully controlled by the makefile rather
than externally (and makes changing how they are manipulated easier).
This commit is contained in:
Ben Boeckel 2014-05-23 14:41:46 -04:00
parent 88818b6805
commit d46c650d67
10 changed files with 38 additions and 69 deletions

View File

@ -84,7 +84,7 @@ cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
this->EscapeAllowMakeVars = false; this->EscapeAllowMakeVars = false;
if(mf) if(mf)
{ {
mf->GetBacktrace(*this->Backtrace); *this->Backtrace = mf->GetBacktrace();
} }
} }

View File

@ -45,7 +45,7 @@ public:
void SetMakefile(cmMakefile *mf) { void SetMakefile(cmMakefile *mf) {
this->Makefile = mf; this->Makefile = mf;
this->Makefile->GetBacktrace(this->Backtrace); this->Backtrace = this->Makefile->GetBacktrace();
} }
protected: protected:

View File

@ -3270,8 +3270,7 @@ void cmFileCommand::AddEvaluationFile(const std::string &inputName,
bool inputIsContent bool inputIsContent
) )
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression outputGe(lfbt); cmGeneratorExpression outputGe(lfbt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> outputCge cmsys::auto_ptr<cmCompiledGeneratorExpression> outputCge

View File

@ -32,8 +32,7 @@ cmInstalledFile::~cmInstalledFile()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmInstalledFile::SetName(cmMakefile* mf, const std::string& name) void cmInstalledFile::SetName(cmMakefile* mf, const std::string& name)
{ {
cmListFileBacktrace backtrace; cmListFileBacktrace backtrace = mf->GetBacktrace();
mf->GetBacktrace(backtrace);
cmGeneratorExpression ge(backtrace); cmGeneratorExpression ge(backtrace);
this->Name = name; this->Name = name;
@ -70,8 +69,7 @@ void cmInstalledFile::SetProperty(cmMakefile const* mf,
void cmInstalledFile::AppendProperty(cmMakefile const* mf, void cmInstalledFile::AppendProperty(cmMakefile const* mf,
const std::string& prop, const char* value, bool /*asString*/) const std::string& prop, const char* value, bool /*asString*/)
{ {
cmListFileBacktrace backtrace; cmListFileBacktrace backtrace = mf->GetBacktrace();
mf->GetBacktrace(backtrace);
cmGeneratorExpression ge(backtrace); cmGeneratorExpression ge(backtrace);
Property& property = this->Properties[prop]; Property& property = this->Properties[prop];

View File

@ -317,7 +317,7 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
{ {
this->CallStack.back().Status->SetNestedError(true); this->CallStack.back().Status->SetNestedError(true);
} }
this->GetBacktrace(backtrace); backtrace = this->GetBacktrace();
} }
else else
{ {
@ -348,12 +348,9 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const cmListFileBacktrace cmMakefile::GetBacktrace() const
{ {
if(this->CallStack.empty()) cmListFileBacktrace backtrace;
{
return false;
}
for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin(); for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin();
i != this->CallStack.rend(); ++i) i != this->CallStack.rend(); ++i)
{ {
@ -362,7 +359,7 @@ bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const
cmLocalGenerator::HOME); cmLocalGenerator::HOME);
backtrace.push_back(lfc); backtrace.push_back(lfc);
} }
return true; return backtrace;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1745,8 +1742,7 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
before ? this->IncludeDirectoriesEntries.begin() before ? this->IncludeDirectoriesEntries.begin()
: this->IncludeDirectoriesEntries.end(); : this->IncludeDirectoriesEntries.end();
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->GetBacktrace();
this->GetBacktrace(lfbt);
cmValueWithOrigin entry(incString, lfbt); cmValueWithOrigin entry(incString, lfbt);
this->IncludeDirectoriesEntries.insert(position, entry); this->IncludeDirectoriesEntries.insert(position, entry);
@ -4013,8 +4009,7 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value)
{ {
return; return;
} }
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->GetBacktrace();
this->GetBacktrace(lfbt);
this->IncludeDirectoriesEntries.push_back( this->IncludeDirectoriesEntries.push_back(
cmValueWithOrigin(value, lfbt)); cmValueWithOrigin(value, lfbt));
return; return;
@ -4026,8 +4021,7 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value)
{ {
return; return;
} }
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->GetBacktrace();
this->GetBacktrace(lfbt);
this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt)); this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt));
return; return;
} }
@ -4038,8 +4032,7 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value)
{ {
return; return;
} }
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->GetBacktrace();
this->GetBacktrace(lfbt);
cmValueWithOrigin entry(value, lfbt); cmValueWithOrigin entry(value, lfbt);
this->CompileDefinitionsEntries.push_back(entry); this->CompileDefinitionsEntries.push_back(entry);
return; return;
@ -4070,24 +4063,21 @@ void cmMakefile::AppendProperty(const std::string& prop,
{ {
if (prop == "INCLUDE_DIRECTORIES") if (prop == "INCLUDE_DIRECTORIES")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->GetBacktrace();
this->GetBacktrace(lfbt);
this->IncludeDirectoriesEntries.push_back( this->IncludeDirectoriesEntries.push_back(
cmValueWithOrigin(value, lfbt)); cmValueWithOrigin(value, lfbt));
return; return;
} }
if (prop == "COMPILE_OPTIONS") if (prop == "COMPILE_OPTIONS")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->GetBacktrace();
this->GetBacktrace(lfbt);
this->CompileOptionsEntries.push_back( this->CompileOptionsEntries.push_back(
cmValueWithOrigin(value, lfbt)); cmValueWithOrigin(value, lfbt));
return; return;
} }
if (prop == "COMPILE_DEFINITIONS") if (prop == "COMPILE_DEFINITIONS")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->GetBacktrace();
this->GetBacktrace(lfbt);
this->CompileDefinitionsEntries.push_back( this->CompileDefinitionsEntries.push_back(
cmValueWithOrigin(value, lfbt)); cmValueWithOrigin(value, lfbt));
return; return;

View File

@ -655,7 +655,7 @@ public:
/** /**
* Get the current context backtrace. * Get the current context backtrace.
*/ */
bool GetBacktrace(cmListFileBacktrace& backtrace) const; cmListFileBacktrace GetBacktrace() const;
/** /**
* Get the vector of files created by this makefile * Get the vector of files created by this makefile

View File

@ -366,7 +366,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
} }
// Save the backtrace of target construction. // Save the backtrace of target construction.
this->Makefile->GetBacktrace(this->Internal->Backtrace); this->Internal->Backtrace = this->Makefile->GetBacktrace();
if (!this->IsImported()) if (!this->IsImported())
{ {
@ -443,7 +443,7 @@ void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
{ {
if(this->Utilities.insert(u).second && makefile) if(this->Utilities.insert(u).second && makefile)
{ {
makefile->GetBacktrace(UtilityBacktraces[u]); UtilityBacktraces.insert(std::make_pair(u, makefile->GetBacktrace()));
} }
} }
@ -910,8 +910,7 @@ void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
{ {
this->Internal->SourceFilesMap.clear(); this->Internal->SourceFilesMap.clear();
this->LinkImplementationLanguageIsContextDependent = true; this->LinkImplementationLanguageIsContextDependent = true;
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
cge->SetEvaluateForBuildsystem(true); cge->SetEvaluateForBuildsystem(true);
@ -948,8 +947,7 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
{ {
this->Internal->SourceFilesMap.clear(); this->Internal->SourceFilesMap.clear();
this->LinkImplementationLanguageIsContextDependent = true; this->LinkImplementationLanguageIsContextDependent = true;
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
cge->SetEvaluateForBuildsystem(true); cge->SetEvaluateForBuildsystem(true);
@ -1084,8 +1082,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src)
{ {
this->Internal->SourceFilesMap.clear(); this->Internal->SourceFilesMap.clear();
this->LinkImplementationLanguageIsContextDependent = true; this->LinkImplementationLanguageIsContextDependent = true;
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src);
cge->SetEvaluateForBuildsystem(true); cge->SetEvaluateForBuildsystem(true);
@ -1306,8 +1303,7 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature)
ret = false; ret = false;
} }
} }
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
this->TLLCommands.push_back(std::make_pair(signature, lfbt)); this->TLLCommands.push_back(std::make_pair(signature, lfbt));
return ret; return ret;
} }
@ -1796,8 +1792,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
} }
if(prop == "INCLUDE_DIRECTORIES") if(prop == "INCLUDE_DIRECTORIES")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
deleteAndClear(this->Internal->IncludeDirectoriesEntries); deleteAndClear(this->Internal->IncludeDirectoriesEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
@ -1807,8 +1802,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
} }
if(prop == "COMPILE_OPTIONS") if(prop == "COMPILE_OPTIONS")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
deleteAndClear(this->Internal->CompileOptionsEntries); deleteAndClear(this->Internal->CompileOptionsEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
@ -1818,8 +1812,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
} }
if(prop == "COMPILE_FEATURES") if(prop == "COMPILE_FEATURES")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
deleteAndClear(this->Internal->CompileFeaturesEntries); deleteAndClear(this->Internal->CompileFeaturesEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
@ -1829,8 +1822,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
} }
if(prop == "COMPILE_DEFINITIONS") if(prop == "COMPILE_DEFINITIONS")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
deleteAndClear(this->Internal->CompileDefinitionsEntries); deleteAndClear(this->Internal->CompileDefinitionsEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
@ -1849,8 +1841,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
if (prop == "LINK_LIBRARIES") if (prop == "LINK_LIBRARIES")
{ {
this->Internal->LinkImplementationPropertyEntries.clear(); this->Internal->LinkImplementationPropertyEntries.clear();
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmValueWithOrigin entry(value, lfbt); cmValueWithOrigin entry(value, lfbt);
this->Internal->LinkImplementationPropertyEntries.push_back(entry); this->Internal->LinkImplementationPropertyEntries.push_back(entry);
return; return;
@ -1866,8 +1857,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
return; return;
} }
this->Internal->SourceFilesMap.clear(); this->Internal->SourceFilesMap.clear();
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
this->Internal->SourceEntries.clear(); this->Internal->SourceEntries.clear();
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
@ -1901,8 +1891,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
} }
if(prop == "INCLUDE_DIRECTORIES") if(prop == "INCLUDE_DIRECTORIES")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
this->Internal->IncludeDirectoriesEntries.push_back( this->Internal->IncludeDirectoriesEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
@ -1910,8 +1899,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
} }
if(prop == "COMPILE_OPTIONS") if(prop == "COMPILE_OPTIONS")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
this->Internal->CompileOptionsEntries.push_back( this->Internal->CompileOptionsEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
@ -1919,8 +1907,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
} }
if(prop == "COMPILE_FEATURES") if(prop == "COMPILE_FEATURES")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
this->Internal->CompileFeaturesEntries.push_back( this->Internal->CompileFeaturesEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
@ -1928,8 +1915,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
} }
if(prop == "COMPILE_DEFINITIONS") if(prop == "COMPILE_DEFINITIONS")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
this->Internal->CompileDefinitionsEntries.push_back( this->Internal->CompileDefinitionsEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
@ -1945,8 +1931,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
} }
if (prop == "LINK_LIBRARIES") if (prop == "LINK_LIBRARIES")
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmValueWithOrigin entry(value, lfbt); cmValueWithOrigin entry(value, lfbt);
this->Internal->LinkImplementationPropertyEntries.push_back(entry); this->Internal->LinkImplementationPropertyEntries.push_back(entry);
return; return;
@ -1962,8 +1947,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
return; return;
} }
this->Internal->SourceFilesMap.clear(); this->Internal->SourceFilesMap.clear();
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
this->Internal->SourceEntries.push_back( this->Internal->SourceEntries.push_back(

View File

@ -55,8 +55,7 @@ bool cmTargetCompileOptionsCommand
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
bool, bool) bool, bool)
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmValueWithOrigin entry(this->Join(content), lfbt); cmValueWithOrigin entry(this->Join(content), lfbt);
tgt->InsertCompileOption(entry); tgt->InsertCompileOption(entry);
return true; return true;

View File

@ -70,8 +70,7 @@ bool cmTargetIncludeDirectoriesCommand
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
bool prepend, bool system) bool prepend, bool system)
{ {
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Makefile->GetBacktrace(lfbt);
cmValueWithOrigin entry(this->Join(content), lfbt); cmValueWithOrigin entry(this->Join(content), lfbt);
tgt->InsertInclude(entry, prepend); tgt->InsertInclude(entry, prepend);
if (system) if (system)

View File

@ -22,7 +22,7 @@ cmTest::cmTest(cmMakefile* mf)
this->OldStyle = true; this->OldStyle = true;
this->Properties.SetCMakeInstance(mf->GetCMakeInstance()); this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
this->Backtrace = new cmListFileBacktrace; this->Backtrace = new cmListFileBacktrace;
this->Makefile->GetBacktrace(*this->Backtrace); *this->Backtrace = this->Makefile->GetBacktrace();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------