cmake: Add IssueMessage overload taking a single cmListFileContext.
Port appropriate clients to use it.
This commit is contained in:
parent
46656aa1fa
commit
8b4b9631f5
|
@ -14,6 +14,7 @@
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
|
#include "cmLocalGenerator.h"
|
||||||
|
|
||||||
#include "cmCommandArgumentLexer.h"
|
#include "cmCommandArgumentLexer.h"
|
||||||
|
|
||||||
|
@ -139,14 +140,14 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
|
||||||
this->Makefile->GetHomeOutputDirectory()))
|
this->Makefile->GetHomeOutputDirectory()))
|
||||||
{
|
{
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
cmListFileBacktrace bt(this->Makefile->GetLocalGenerator());
|
|
||||||
cmListFileContext lfc;
|
cmListFileContext lfc;
|
||||||
lfc.FilePath = this->FileName;
|
lfc.FilePath = this->Makefile->GetLocalGenerator()
|
||||||
|
->Convert(this->FileName, cmLocalGenerator::HOME);
|
||||||
|
|
||||||
lfc.Line = this->FileLine;
|
lfc.Line = this->FileLine;
|
||||||
bt.Append(lfc);
|
|
||||||
msg << "uninitialized variable \'" << var << "\'";
|
msg << "uninitialized variable \'" << var << "\'";
|
||||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
||||||
msg.str(), bt);
|
msg.str(), lfc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -249,19 +249,13 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
|
||||||
std::string const& text) const
|
std::string const& text) const
|
||||||
{
|
{
|
||||||
// Collect context information.
|
// Collect context information.
|
||||||
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))
|
||||||
{
|
{
|
||||||
this->CallStack.back().Status->SetNestedError(true);
|
this->CallStack.back().Status->SetNestedError(true);
|
||||||
}
|
}
|
||||||
backtrace = this->GetBacktrace();
|
this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -278,12 +272,15 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
|
||||||
// command. Add whatever context information we have.
|
// command. Add whatever context information we have.
|
||||||
lfc.FilePath = this->ListFileStack.back();
|
lfc.FilePath = this->ListFileStack.back();
|
||||||
}
|
}
|
||||||
|
if(!this->CallStack.empty()
|
||||||
|
|| !this->GetCMakeInstance()->GetIsInTryCompile())
|
||||||
|
{
|
||||||
|
lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
|
||||||
|
cmLocalGenerator::HOME);
|
||||||
|
}
|
||||||
lfc.Line = 0;
|
lfc.Line = 0;
|
||||||
backtrace.Append(lfc);
|
this->GetCMakeInstance()->IssueMessage(t, text, lfc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue the message.
|
|
||||||
this->GetCMakeInstance()->IssueMessage(t, text, backtrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -1837,22 +1834,22 @@ void cmMakefile::LogUnused(const char* reason,
|
||||||
if (this->WarnUnused)
|
if (this->WarnUnused)
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
cmListFileBacktrace bt(this->GetLocalGenerator());
|
cmListFileContext lfc;
|
||||||
if (!this->CallStack.empty())
|
if (!this->CallStack.empty())
|
||||||
{
|
{
|
||||||
cmListFileContext file = this->GetExecutionContext();
|
lfc = this->GetExecutionContext();
|
||||||
bt.Append(file);
|
path = lfc.FilePath;
|
||||||
path = file.FilePath;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
path = this->GetCurrentSourceDirectory();
|
path = this->GetCurrentSourceDirectory();
|
||||||
path += "/CMakeLists.txt";
|
path += "/CMakeLists.txt";
|
||||||
cmListFileContext lfc;
|
|
||||||
lfc.FilePath = path;
|
lfc.FilePath = path;
|
||||||
lfc.Line = 0;
|
lfc.Line = 0;
|
||||||
bt.Append(lfc);
|
|
||||||
}
|
}
|
||||||
|
lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
|
||||||
|
cmLocalGenerator::HOME);
|
||||||
|
|
||||||
if (this->CheckSystemVars ||
|
if (this->CheckSystemVars ||
|
||||||
cmSystemTools::IsSubDirectory(path,
|
cmSystemTools::IsSubDirectory(path,
|
||||||
this->GetHomeDirectory()) ||
|
this->GetHomeDirectory()) ||
|
||||||
|
@ -1865,7 +1862,7 @@ void cmMakefile::LogUnused(const char* reason,
|
||||||
msg << "unused variable (" << reason << ") \'" << name << "\'";
|
msg << "unused variable (" << reason << ") \'" << name << "\'";
|
||||||
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
||||||
msg.str(),
|
msg.str(),
|
||||||
bt);
|
lfc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2769,14 +2766,13 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
|
||||||
this->GetHomeOutputDirectory()))
|
this->GetHomeOutputDirectory()))
|
||||||
{
|
{
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
cmListFileBacktrace bt(this->GetLocalGenerator());
|
|
||||||
cmListFileContext lfc;
|
cmListFileContext lfc;
|
||||||
lfc.FilePath = filename;
|
lfc.FilePath = this->LocalGenerator
|
||||||
|
->Convert(filename, cmLocalGenerator::HOME);
|
||||||
lfc.Line = line;
|
lfc.Line = line;
|
||||||
bt.Append(lfc);
|
|
||||||
msg << "uninitialized variable \'" << lookup << "\'";
|
msg << "uninitialized variable \'" << lookup << "\'";
|
||||||
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
||||||
msg.str(), bt);
|
msg.str(), lfc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2552,6 +2552,24 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
||||||
displayMessage(t, msg);
|
displayMessage(t, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
||||||
|
cmListFileContext const& lfc)
|
||||||
|
{
|
||||||
|
std::ostringstream msg;
|
||||||
|
if (!this->PrintMessagePreamble(t, msg))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the immediate context.
|
||||||
|
msg << (lfc.Line ? " at " : " in ") << lfc;
|
||||||
|
|
||||||
|
printMessageText(msg, text);
|
||||||
|
|
||||||
|
displayMessage(t, msg);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::vector<std::string> cmake::GetDebugConfigs()
|
std::vector<std::string> cmake::GetDebugConfigs()
|
||||||
{
|
{
|
||||||
|
|
|
@ -303,6 +303,9 @@ 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(NULL));
|
cmListFileBacktrace const& backtrace = cmListFileBacktrace(NULL));
|
||||||
|
void IssueMessage(cmake::MessageType t, std::string const& text,
|
||||||
|
cmListFileContext const& lfc);
|
||||||
|
|
||||||
///! 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