cmCustomCommand: Explicitly pass backtrace on construction

This commit is contained in:
Daniel Eiband
2019-10-17 16:15:44 +02:00
parent 3dc084ebc1
commit 96e5042e46
8 changed files with 25 additions and 29 deletions

View File

@@ -5,26 +5,22 @@
#include <utility> #include <utility>
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmMakefile.h"
cmCustomCommand::cmCustomCommand(cmMakefile const* mf, cmCustomCommand::cmCustomCommand(std::vector<std::string> outputs,
std::vector<std::string> outputs,
std::vector<std::string> byproducts, std::vector<std::string> byproducts,
std::vector<std::string> depends, std::vector<std::string> depends,
cmCustomCommandLines commandLines, cmCustomCommandLines commandLines,
const char* comment, cmListFileBacktrace lfbt, const char* comment,
const char* workingDirectory) const char* workingDirectory)
: Outputs(std::move(outputs)) : Outputs(std::move(outputs))
, Byproducts(std::move(byproducts)) , Byproducts(std::move(byproducts))
, Depends(std::move(depends)) , Depends(std::move(depends))
, CommandLines(std::move(commandLines)) , CommandLines(std::move(commandLines))
, Backtrace(std::move(lfbt))
, Comment(comment ? comment : "") , Comment(comment ? comment : "")
, WorkingDirectory(workingDirectory ? workingDirectory : "") , WorkingDirectory(workingDirectory ? workingDirectory : "")
, HaveComment(comment != nullptr) , HaveComment(comment != nullptr)
{ {
if (mf) {
this->Backtrace = mf->GetBacktrace();
}
} }
const std::vector<std::string>& cmCustomCommand::GetOutputs() const const std::vector<std::string>& cmCustomCommand::GetOutputs() const

View File

@@ -12,8 +12,6 @@
#include "cmCustomCommandLines.h" #include "cmCustomCommandLines.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
class cmMakefile;
class cmImplicitDependsList class cmImplicitDependsList
: public std::vector<std::pair<std::string, std::string>> : public std::vector<std::pair<std::string, std::string>>
{ {
@@ -28,11 +26,11 @@ class cmCustomCommand
{ {
public: public:
/** Main constructor specifies all information for the command. */ /** Main constructor specifies all information for the command. */
cmCustomCommand(cmMakefile const* mf, std::vector<std::string> outputs, cmCustomCommand(std::vector<std::string> outputs,
std::vector<std::string> byproducts, std::vector<std::string> byproducts,
std::vector<std::string> depends, std::vector<std::string> depends,
cmCustomCommandLines commandLines, const char* comment, cmCustomCommandLines commandLines, cmListFileBacktrace lfbt,
const char* workingDirectory); const char* comment, const char* workingDirectory);
/** 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;

View File

@@ -2651,8 +2651,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
std::vector<std::string> no_byproducts; std::vector<std::string> no_byproducts;
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(nullptr, no_outputs, no_byproducts, no_depends, cmCustomCommand cc(no_outputs, no_byproducts, no_depends, gti.CommandLines,
gti.CommandLines, nullptr, gti.WorkingDir.c_str()); cmListFileBacktrace(), nullptr, gti.WorkingDir.c_str());
cc.SetUsesTerminal(gti.UsesTerminal); cc.SetUsesTerminal(gti.UsesTerminal);
target.AddPostBuildCommand(std::move(cc)); target.AddPostBuildCommand(std::move(cc));
if (!gti.Message.empty()) { if (!gti.Message.empty()) {

View File

@@ -930,9 +930,10 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
cmCustomCommandLines commandLines = cmMakeSingleCommandLine( cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
{ cmakeCommand, "-E", "__create_def", mdi->DefFile, objs_file }); { cmakeCommand, "-E", "__create_def", mdi->DefFile, objs_file });
cmCustomCommand command(gt->Target->GetMakefile(), outputs, empty, empty, cmCustomCommand command(outputs, empty, empty, commandLines,
commandLines, "Auto build dll exports", "."); gt->Target->GetMakefile()->GetBacktrace(),
commands.push_back(command); "Auto build dll exports", ".");
commands.push_back(std::move(command));
} }
static bool OpenSolution(std::string sln) static bool OpenSolution(std::string sln)

View File

@@ -1462,12 +1462,12 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
{ cmSystemTools::GetCMakeCommand(), "-E", "cmake_symlink_library", { cmSystemTools::GetCMakeCommand(), "-E", "cmake_symlink_library",
str_file, str_so_file, str_link_file }); str_file, str_so_file, str_link_file });
cmCustomCommand command(this->CurrentMakefile, std::vector<std::string>(), cmCustomCommand command(
std::vector<std::string>(), std::vector<std::string>(), std::vector<std::string>(),
std::vector<std::string>(), cmd, std::vector<std::string>(), cmd, this->CurrentMakefile->GetBacktrace(),
"Creating symlinks", ""); "Creating symlinks", "");
postbuild.push_back(command); postbuild.push_back(std::move(command));
} }
std::vector<cmSourceFile*> classes; std::vector<cmSourceFile*> classes;

View File

@@ -104,8 +104,8 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
std::vector<std::string> no_depends; std::vector<std::string> no_depends;
cmCustomCommandLines commands = cmMakeSingleCommandLine( cmCustomCommandLines commands = cmMakeSingleCommandLine(
{ cmSystemTools::GetCMakeCommand(), "-E", "make_directory", impDir }); { cmSystemTools::GetCMakeCommand(), "-E", "make_directory", impDir });
pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, no_depends, pcc.reset(new cmCustomCommand(no_output, no_byproducts, no_depends, commands,
commands, 0, 0)); cmListFileBacktrace(), nullptr, nullptr));
pcc->SetEscapeOldStyle(false); pcc->SetEscapeOldStyle(false);
pcc->SetEscapeAllowMakeVars(true); pcc->SetEscapeAllowMakeVars(true);
return pcc; return pcc;

View File

@@ -946,8 +946,8 @@ void cmMakefile::CommitCustomCommandToTarget(
{ {
// 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(this, no_output, byproducts, depends, commandLines, cmCustomCommand cc(no_output, byproducts, depends, commandLines,
comment, workingDir); this->Backtrace, comment, workingDir);
cc.SetEscapeOldStyle(escapeOldStyle); cc.SetEscapeOldStyle(escapeOldStyle);
cc.SetEscapeAllowMakeVars(true); cc.SetEscapeAllowMakeVars(true);
cc.SetUsesTerminal(uses_terminal); cc.SetUsesTerminal(uses_terminal);
@@ -1083,7 +1083,8 @@ cmSourceFile* cmMakefile::CommitCustomCommandToOutput(
} }
std::unique_ptr<cmCustomCommand> cc = cm::make_unique<cmCustomCommand>( std::unique_ptr<cmCustomCommand> cc = cm::make_unique<cmCustomCommand>(
this, outputs, byproducts, depends2, commandLines, comment, workingDir); outputs, byproducts, depends2, commandLines, this->Backtrace, comment,
workingDir);
cc->SetEscapeOldStyle(escapeOldStyle); cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetEscapeAllowMakeVars(true); cc->SetEscapeAllowMakeVars(true);
cc->SetImplicitDepends(implicit_depends); cc->SetImplicitDepends(implicit_depends);

View File

@@ -1082,8 +1082,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
// PRE_BUILD does not support file dependencies! // PRE_BUILD does not support file dependencies!
const std::vector<std::string> no_output; const std::vector<std::string> no_output;
const std::vector<std::string> no_deps; const std::vector<std::string> no_deps;
cmCustomCommand cc(this->Makefile, no_output, autogenProvides, no_deps, cmCustomCommand cc(no_output, autogenProvides, no_deps, commandLines,
commandLines, autogenComment.c_str(), this->Makefile->GetBacktrace(), autogenComment.c_str(),
this->Dir.Work.c_str()); this->Dir.Work.c_str());
cc.SetEscapeOldStyle(false); cc.SetEscapeOldStyle(false);
cc.SetEscapeAllowMakeVars(true); cc.SetEscapeAllowMakeVars(true);