backtrace: Convert to local paths in IssueMessage
This is the only place we care show the FilePath to the user, so defer the expensive relative path calculation until here.
This commit is contained in:
parent
a08292059e
commit
2a1b2d8486
|
@ -137,7 +137,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
|
||||||
this->Makefile->GetHomeOutputDirectory()))
|
this->Makefile->GetHomeOutputDirectory()))
|
||||||
{
|
{
|
||||||
cmOStringStream msg;
|
cmOStringStream msg;
|
||||||
cmListFileBacktrace bt;
|
cmListFileBacktrace bt(this->Makefile->GetLocalGenerator());
|
||||||
cmListFileContext lfc;
|
cmListFileContext lfc;
|
||||||
lfc.FilePath = this->FileName;
|
lfc.FilePath = this->FileName;
|
||||||
lfc.Line = this->FileLine;
|
lfc.Line = this->FileLine;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmCustomCommand::cmCustomCommand()
|
cmCustomCommand::cmCustomCommand()
|
||||||
|
: Backtrace(NULL)
|
||||||
{
|
{
|
||||||
this->HaveComment = false;
|
this->HaveComment = false;
|
||||||
this->EscapeOldStyle = true;
|
this->EscapeOldStyle = true;
|
||||||
|
@ -73,7 +74,8 @@ cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
|
||||||
Comment(comment?comment:""),
|
Comment(comment?comment:""),
|
||||||
WorkingDirectory(workingDirectory?workingDirectory:""),
|
WorkingDirectory(workingDirectory?workingDirectory:""),
|
||||||
EscapeAllowMakeVars(false),
|
EscapeAllowMakeVars(false),
|
||||||
EscapeOldStyle(true)
|
EscapeOldStyle(true),
|
||||||
|
Backtrace(NULL)
|
||||||
{
|
{
|
||||||
this->EscapeOldStyle = true;
|
this->EscapeOldStyle = true;
|
||||||
this->EscapeAllowMakeVars = false;
|
this->EscapeAllowMakeVars = false;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmExportBuildFileGenerator::cmExportBuildFileGenerator()
|
cmExportBuildFileGenerator::cmExportBuildFileGenerator()
|
||||||
|
: Backtrace(NULL)
|
||||||
{
|
{
|
||||||
this->Makefile = 0;
|
this->Makefile = 0;
|
||||||
this->ExportSet = 0;
|
this->ExportSet = 0;
|
||||||
|
|
|
@ -35,7 +35,7 @@ cmGeneratorExpression::Parse(std::string const& input)
|
||||||
{
|
{
|
||||||
return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
|
return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
|
||||||
new cmCompiledGeneratorExpression(
|
new cmCompiledGeneratorExpression(
|
||||||
this->Backtrace ? *this->Backtrace : cmListFileBacktrace(),
|
this->Backtrace ? *this->Backtrace : cmListFileBacktrace(NULL),
|
||||||
input));
|
input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
|
||||||
const GeneratorExpressionContent *content,
|
const GeneratorExpressionContent *content,
|
||||||
cmGeneratorExpressionDAGChecker *parent)
|
cmGeneratorExpressionDAGChecker *parent)
|
||||||
: Parent(parent), Target(target), Property(property),
|
: Parent(parent), Target(target), Property(property),
|
||||||
Content(content), TransitivePropertiesOnly(false)
|
Content(content), Backtrace(NULL), TransitivePropertiesOnly(false)
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ class cmTarget;
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
struct cmGeneratorExpressionContext
|
struct cmGeneratorExpressionContext
|
||||||
{
|
{
|
||||||
|
cmGeneratorExpressionContext()
|
||||||
|
: Backtrace(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
cmListFileBacktrace Backtrace;
|
cmListFileBacktrace Backtrace;
|
||||||
std::set<cmTarget*> DependTargets;
|
std::set<cmTarget*> DependTargets;
|
||||||
std::set<cmTarget const*> AllTargets;
|
std::set<cmTarget const*> AllTargets;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
|
|
||||||
#include "cmListFileLexer.h"
|
#include "cmListFileLexer.h"
|
||||||
|
#include "cmLocalGenerator.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmVersion.h"
|
#include "cmVersion.h"
|
||||||
|
@ -407,6 +408,23 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmListFileBacktrace::MakeRelative()
|
||||||
|
{
|
||||||
|
if (this->Relative)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (cmListFileBacktrace::iterator i = this->begin();
|
||||||
|
i != this->end(); ++i)
|
||||||
|
{
|
||||||
|
i->FilePath = this->LocalGenerator->Convert(i->FilePath,
|
||||||
|
cmLocalGenerator::HOME);
|
||||||
|
}
|
||||||
|
this->Relative = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
|
std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
|
||||||
|
class cmLocalGenerator;
|
||||||
|
|
||||||
/** \class cmListFileCache
|
/** \class cmListFileCache
|
||||||
* \brief A class to cache list file contents.
|
* \brief A class to cache list file contents.
|
||||||
*
|
*
|
||||||
|
@ -66,7 +68,20 @@ struct cmListFileFunction: public cmListFileContext
|
||||||
std::vector<cmListFileArgument> Arguments;
|
std::vector<cmListFileArgument> Arguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
class cmListFileBacktrace: public std::vector<cmListFileContext> {};
|
class cmListFileBacktrace: public std::vector<cmListFileContext>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cmListFileBacktrace(cmLocalGenerator* localGen)
|
||||||
|
: LocalGenerator(localGen)
|
||||||
|
, Relative(localGen ? false : true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MakeRelative();
|
||||||
|
private:
|
||||||
|
cmLocalGenerator* LocalGenerator;
|
||||||
|
bool Relative;
|
||||||
|
};
|
||||||
|
|
||||||
struct cmListFile
|
struct cmListFile
|
||||||
{
|
{
|
||||||
|
|
|
@ -310,7 +310,12 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
|
||||||
std::string const& text) const
|
std::string const& text) const
|
||||||
{
|
{
|
||||||
// Collect context information.
|
// Collect context information.
|
||||||
cmListFileBacktrace backtrace;
|
cmLocalGenerator* localGen = this->GetLocalGenerator();
|
||||||
|
if(this->CallStack.empty() && this->GetCMakeInstance()->GetIsInTryCompile())
|
||||||
|
{
|
||||||
|
localGen = 0;
|
||||||
|
}
|
||||||
|
cmListFileBacktrace backtrace(localGen);
|
||||||
if(!this->CallStack.empty())
|
if(!this->CallStack.empty())
|
||||||
{
|
{
|
||||||
if((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR))
|
if((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR))
|
||||||
|
@ -335,11 +340,6 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
|
||||||
lfc.FilePath = this->ListFileStack.back();
|
lfc.FilePath = this->ListFileStack.back();
|
||||||
}
|
}
|
||||||
lfc.Line = 0;
|
lfc.Line = 0;
|
||||||
if(!this->GetCMakeInstance()->GetIsInTryCompile())
|
|
||||||
{
|
|
||||||
lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
|
|
||||||
cmLocalGenerator::HOME);
|
|
||||||
}
|
|
||||||
backtrace.push_back(lfc);
|
backtrace.push_back(lfc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,14 +350,11 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmListFileBacktrace cmMakefile::GetBacktrace() const
|
cmListFileBacktrace cmMakefile::GetBacktrace() const
|
||||||
{
|
{
|
||||||
cmListFileBacktrace backtrace;
|
cmListFileBacktrace backtrace(this->GetLocalGenerator());
|
||||||
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)
|
||||||
{
|
{
|
||||||
cmListFileContext lfc = *(*i).Context;
|
backtrace.push_back(*i->Context);
|
||||||
lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
|
|
||||||
cmLocalGenerator::HOME);
|
|
||||||
backtrace.push_back(lfc);
|
|
||||||
}
|
}
|
||||||
return backtrace;
|
return backtrace;
|
||||||
}
|
}
|
||||||
|
@ -1919,7 +1916,7 @@ void cmMakefile::CheckForUnused(const char* reason,
|
||||||
if (this->WarnUnused && !this->VariableUsed(name))
|
if (this->WarnUnused && !this->VariableUsed(name))
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
cmListFileBacktrace bt;
|
cmListFileBacktrace bt(this->GetLocalGenerator());
|
||||||
if (this->CallStack.size())
|
if (this->CallStack.size())
|
||||||
{
|
{
|
||||||
const cmListFileContext* file = this->CallStack.back().Context;
|
const cmListFileContext* file = this->CallStack.back().Context;
|
||||||
|
@ -2870,7 +2867,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
|
||||||
this->GetHomeOutputDirectory()))
|
this->GetHomeOutputDirectory()))
|
||||||
{
|
{
|
||||||
cmOStringStream msg;
|
cmOStringStream msg;
|
||||||
cmListFileBacktrace bt;
|
cmListFileBacktrace bt(this->GetLocalGenerator());
|
||||||
cmListFileContext lfc;
|
cmListFileContext lfc;
|
||||||
lfc.FilePath = filename;
|
lfc.FilePath = filename;
|
||||||
lfc.Line = line;
|
lfc.Line = line;
|
||||||
|
|
|
@ -87,10 +87,12 @@ class cmTargetInternals
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmTargetInternals()
|
cmTargetInternals()
|
||||||
|
: Backtrace(NULL)
|
||||||
{
|
{
|
||||||
this->PolicyWarnedCMP0022 = false;
|
this->PolicyWarnedCMP0022 = false;
|
||||||
}
|
}
|
||||||
cmTargetInternals(cmTargetInternals const&)
|
cmTargetInternals(cmTargetInternals const&)
|
||||||
|
: Backtrace(NULL)
|
||||||
{
|
{
|
||||||
this->PolicyWarnedCMP0022 = false;
|
this->PolicyWarnedCMP0022 = false;
|
||||||
}
|
}
|
||||||
|
@ -1324,9 +1326,10 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s,
|
||||||
: "plain");
|
: "plain");
|
||||||
s << "The uses of the " << sigString << " signature are here:\n";
|
s << "The uses of the " << sigString << " signature are here:\n";
|
||||||
std::set<std::string> emitted;
|
std::set<std::string> emitted;
|
||||||
for(std::vector<cmListFileBacktrace>::const_iterator it = sigs.begin();
|
for(std::vector<cmListFileBacktrace>::iterator it = sigs.begin();
|
||||||
it != sigs.end(); ++it)
|
it != sigs.end(); ++it)
|
||||||
{
|
{
|
||||||
|
it->MakeRelative();
|
||||||
cmListFileBacktrace::const_iterator i = it->begin();
|
cmListFileBacktrace::const_iterator i = it->begin();
|
||||||
if(i != it->end())
|
if(i != it->end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmTest::cmTest(cmMakefile* mf)
|
cmTest::cmTest(cmMakefile* mf)
|
||||||
|
: Backtrace(mf->GetBacktrace())
|
||||||
{
|
{
|
||||||
this->Makefile = mf;
|
this->Makefile = mf;
|
||||||
this->OldStyle = true;
|
this->OldStyle = true;
|
||||||
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
|
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
|
||||||
this->Backtrace = this->Makefile->GetBacktrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -2562,8 +2562,11 @@ static bool cmakeCheckStampList(const char* stampList)
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
||||||
cmListFileBacktrace const& backtrace)
|
cmListFileBacktrace const& bt)
|
||||||
{
|
{
|
||||||
|
cmListFileBacktrace backtrace = bt;
|
||||||
|
backtrace.MakeRelative();
|
||||||
|
|
||||||
cmOStringStream msg;
|
cmOStringStream msg;
|
||||||
bool isError = false;
|
bool isError = false;
|
||||||
// Construct the message header.
|
// Construct the message header.
|
||||||
|
|
|
@ -360,7 +360,7 @@ class cmake
|
||||||
|
|
||||||
/** Display a message to the user. */
|
/** Display a message to the user. */
|
||||||
void IssueMessage(cmake::MessageType t, std::string const& text,
|
void IssueMessage(cmake::MessageType t, std::string const& text,
|
||||||
cmListFileBacktrace const& backtrace = cmListFileBacktrace());
|
cmListFileBacktrace const& backtrace = cmListFileBacktrace(NULL));
|
||||||
///! run the --build option
|
///! run the --build option
|
||||||
int Build(const std::string& dir,
|
int Build(const std::string& dir,
|
||||||
const std::string& target,
|
const std::string& target,
|
||||||
|
|
Loading…
Reference in New Issue