Record backtrace in cmCustomCommand
This will be used to report custom command errors to the user with a backtrace pointing at the add_custom_command or add_custom_target call.
This commit is contained in:
parent
53ea8b3204
commit
bfb7288f81
|
@ -11,6 +11,8 @@
|
||||||
============================================================================*/
|
============================================================================*/
|
||||||
#include "cmCustomCommand.h"
|
#include "cmCustomCommand.h"
|
||||||
|
|
||||||
|
#include "cmMakefile.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmCustomCommand::cmCustomCommand()
|
cmCustomCommand::cmCustomCommand()
|
||||||
{
|
{
|
||||||
|
@ -28,12 +30,14 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
|
||||||
Comment(r.Comment),
|
Comment(r.Comment),
|
||||||
WorkingDirectory(r.WorkingDirectory),
|
WorkingDirectory(r.WorkingDirectory),
|
||||||
EscapeAllowMakeVars(r.EscapeAllowMakeVars),
|
EscapeAllowMakeVars(r.EscapeAllowMakeVars),
|
||||||
EscapeOldStyle(r.EscapeOldStyle)
|
EscapeOldStyle(r.EscapeOldStyle),
|
||||||
|
Backtrace(new cmListFileBacktrace(*r.Backtrace))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmCustomCommand::cmCustomCommand(const std::vector<std::string>& outputs,
|
cmCustomCommand::cmCustomCommand(cmMakefile* mf,
|
||||||
|
const std::vector<std::string>& outputs,
|
||||||
const std::vector<std::string>& depends,
|
const std::vector<std::string>& depends,
|
||||||
const cmCustomCommandLines& commandLines,
|
const cmCustomCommandLines& commandLines,
|
||||||
const char* comment,
|
const char* comment,
|
||||||
|
@ -45,10 +49,21 @@ cmCustomCommand::cmCustomCommand(const std::vector<std::string>& outputs,
|
||||||
Comment(comment?comment:""),
|
Comment(comment?comment:""),
|
||||||
WorkingDirectory(workingDirectory?workingDirectory:""),
|
WorkingDirectory(workingDirectory?workingDirectory:""),
|
||||||
EscapeAllowMakeVars(false),
|
EscapeAllowMakeVars(false),
|
||||||
EscapeOldStyle(true)
|
EscapeOldStyle(true),
|
||||||
|
Backtrace(new cmListFileBacktrace)
|
||||||
{
|
{
|
||||||
this->EscapeOldStyle = true;
|
this->EscapeOldStyle = true;
|
||||||
this->EscapeAllowMakeVars = false;
|
this->EscapeAllowMakeVars = false;
|
||||||
|
if(mf)
|
||||||
|
{
|
||||||
|
mf->GetBacktrace(*this->Backtrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
cmCustomCommand::~cmCustomCommand()
|
||||||
|
{
|
||||||
|
delete this->Backtrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -130,6 +145,12 @@ void cmCustomCommand::SetEscapeAllowMakeVars(bool b)
|
||||||
this->EscapeAllowMakeVars = b;
|
this->EscapeAllowMakeVars = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
|
||||||
|
{
|
||||||
|
return *this->Backtrace;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmCustomCommand::ImplicitDependsList const&
|
cmCustomCommand::ImplicitDependsList const&
|
||||||
cmCustomCommand::GetImplicitDepends() const
|
cmCustomCommand::GetImplicitDepends() const
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#define cmCustomCommand_h
|
#define cmCustomCommand_h
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
class cmMakefile;
|
||||||
|
class cmListFileBacktrace;
|
||||||
|
|
||||||
/** \class cmCustomCommand
|
/** \class cmCustomCommand
|
||||||
* \brief A class to encapsulate a custom command
|
* \brief A class to encapsulate a custom command
|
||||||
|
@ -27,12 +29,15 @@ public:
|
||||||
cmCustomCommand(const cmCustomCommand& r);
|
cmCustomCommand(const cmCustomCommand& r);
|
||||||
|
|
||||||
/** Main constructor specifies all information for the command. */
|
/** Main constructor specifies all information for the command. */
|
||||||
cmCustomCommand(const std::vector<std::string>& outputs,
|
cmCustomCommand(cmMakefile* mf,
|
||||||
|
const std::vector<std::string>& outputs,
|
||||||
const std::vector<std::string>& depends,
|
const std::vector<std::string>& depends,
|
||||||
const cmCustomCommandLines& commandLines,
|
const cmCustomCommandLines& commandLines,
|
||||||
const char* comment,
|
const char* comment,
|
||||||
const char* workingDirectory);
|
const char* workingDirectory);
|
||||||
|
|
||||||
|
~cmCustomCommand();
|
||||||
|
|
||||||
/** Get the output file produced by the command. */
|
/** Get the output file produced by the command. */
|
||||||
const std::vector<std::string>& GetOutputs() const;
|
const std::vector<std::string>& GetOutputs() const;
|
||||||
|
|
||||||
|
@ -63,6 +68,9 @@ public:
|
||||||
bool GetEscapeAllowMakeVars() const;
|
bool GetEscapeAllowMakeVars() const;
|
||||||
void SetEscapeAllowMakeVars(bool b);
|
void SetEscapeAllowMakeVars(bool b);
|
||||||
|
|
||||||
|
/** Backtrace of the command that created this custom command. */
|
||||||
|
cmListFileBacktrace const& GetBacktrace() const;
|
||||||
|
|
||||||
typedef std::pair<cmStdString, cmStdString> ImplicitDependsPair;
|
typedef std::pair<cmStdString, cmStdString> ImplicitDependsPair;
|
||||||
class ImplicitDependsList: public std::vector<ImplicitDependsPair> {};
|
class ImplicitDependsList: public std::vector<ImplicitDependsPair> {};
|
||||||
void SetImplicitDepends(ImplicitDependsList const&);
|
void SetImplicitDepends(ImplicitDependsList const&);
|
||||||
|
@ -78,6 +86,7 @@ private:
|
||||||
std::string WorkingDirectory;
|
std::string WorkingDirectory;
|
||||||
bool EscapeAllowMakeVars;
|
bool EscapeAllowMakeVars;
|
||||||
bool EscapeOldStyle;
|
bool EscapeOldStyle;
|
||||||
|
cmListFileBacktrace* Backtrace;
|
||||||
ImplicitDependsList ImplicitDepends;
|
ImplicitDependsList ImplicitDepends;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1893,7 +1893,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
|
||||||
std::vector<std::string> no_outputs;
|
std::vector<std::string> no_outputs;
|
||||||
std::vector<std::string> no_depends;
|
std::vector<std::string> no_depends;
|
||||||
// Store the custom command in the target.
|
// Store the custom command in the target.
|
||||||
cmCustomCommand cc(no_outputs, no_depends, *commandLines, 0,
|
cmCustomCommand cc(0, no_outputs, no_depends, *commandLines, 0,
|
||||||
workingDirectory);
|
workingDirectory);
|
||||||
target.GetPostBuildCommands().push_back(cc);
|
target.GetPostBuildCommands().push_back(cc);
|
||||||
target.SetProperty("EchoString", message);
|
target.SetProperty("EchoString", message);
|
||||||
|
|
|
@ -838,7 +838,7 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
|
||||||
std::vector<std::string> no_depends;
|
std::vector<std::string> no_depends;
|
||||||
cmCustomCommandLines commands;
|
cmCustomCommandLines commands;
|
||||||
commands.push_back(command);
|
commands.push_back(command);
|
||||||
pcc.reset(new cmCustomCommand(no_output, no_depends, commands, 0, 0));
|
pcc.reset(new cmCustomCommand(0, no_output, no_depends, commands, 0, 0));
|
||||||
pcc->SetEscapeOldStyle(false);
|
pcc->SetEscapeOldStyle(false);
|
||||||
pcc->SetEscapeAllowMakeVars(true);
|
pcc->SetEscapeAllowMakeVars(true);
|
||||||
return pcc;
|
return pcc;
|
||||||
|
|
|
@ -53,7 +53,7 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
|
||||||
std::vector<std::string> no_depends;
|
std::vector<std::string> no_depends;
|
||||||
cmCustomCommandLines commands;
|
cmCustomCommandLines commands;
|
||||||
commands.push_back(command);
|
commands.push_back(command);
|
||||||
pcc.reset(new cmCustomCommand(no_output, no_depends, commands, 0, 0));
|
pcc.reset(new cmCustomCommand(0, no_output, no_depends, commands, 0, 0));
|
||||||
pcc->SetEscapeOldStyle(false);
|
pcc->SetEscapeOldStyle(false);
|
||||||
pcc->SetEscapeAllowMakeVars(true);
|
pcc->SetEscapeAllowMakeVars(true);
|
||||||
return pcc;
|
return pcc;
|
||||||
|
|
|
@ -827,7 +827,8 @@ cmMakefile::AddCustomCommandToTarget(const char* target,
|
||||||
{
|
{
|
||||||
// Add the command to the appropriate build step for the target.
|
// Add the command to the appropriate build step for the target.
|
||||||
std::vector<std::string> no_output;
|
std::vector<std::string> no_output;
|
||||||
cmCustomCommand cc(no_output, depends, commandLines, comment, workingDir);
|
cmCustomCommand cc(this, no_output, depends,
|
||||||
|
commandLines, comment, workingDir);
|
||||||
cc.SetEscapeOldStyle(escapeOldStyle);
|
cc.SetEscapeOldStyle(escapeOldStyle);
|
||||||
cc.SetEscapeAllowMakeVars(true);
|
cc.SetEscapeAllowMakeVars(true);
|
||||||
switch(type)
|
switch(type)
|
||||||
|
@ -947,7 +948,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
|
||||||
if(file)
|
if(file)
|
||||||
{
|
{
|
||||||
cmCustomCommand* cc =
|
cmCustomCommand* cc =
|
||||||
new cmCustomCommand(outputs, depends2, commandLines,
|
new cmCustomCommand(this, outputs, depends2, commandLines,
|
||||||
comment, workingDir);
|
comment, workingDir);
|
||||||
cc->SetEscapeOldStyle(escapeOldStyle);
|
cc->SetEscapeOldStyle(escapeOldStyle);
|
||||||
cc->SetEscapeAllowMakeVars(true);
|
cc->SetEscapeAllowMakeVars(true);
|
||||||
|
|
Loading…
Reference in New Issue