cmMakefile: Simplify detail:::Add{Custom,Utility}Command

Note 1: `detail::AddCustomCommandToTarget()` resets cc,
since cc is not moved away.

Note 2: In `detail::AddUtilityCommand()`, a few vars are preserved
before using. Their refs will be alive in most cases, but cc might
be destroyed in the future.
This commit is contained in:
NAKAMURA Takumi
2021-11-14 17:22:33 +09:00
committed by Brad King
parent 90e1206f25
commit e37511ae7e
4 changed files with 180 additions and 185 deletions

View File

@@ -1072,11 +1072,22 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget(
return nullptr; return nullptr;
} }
detail::AddCustomCommandToTarget( auto cc = cm::make_unique<cmCustomCommand>();
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, t, byproducts, cc->SetBacktrace(this->DirectoryBacktrace);
depends, commandLines, type, comment, workingDir, escapeOldStyle, cc->SetByproducts(byproducts);
uses_terminal, depfile, job_pool, command_expand_lists, stdPipesUTF8, cc->SetDepends(depends);
cmp0116); cc->SetCommandLines(commandLines);
cc->SetComment(comment);
cc->SetWorkingDirectory(workingDir);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetUsesTerminal(uses_terminal);
cc->SetDepfile(depfile);
cc->SetJobPool(job_pool);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetStdPipesUTF8(stdPipesUTF8);
cc->SetCMP0116Status(cmp0116);
detail::AddCustomCommandToTarget(*this, cmCommandOrigin::Generator, t, type,
std::move(cc));
return t; return t;
} }
@@ -1113,11 +1124,25 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput(
return nullptr; return nullptr;
} }
return detail::AddCustomCommandToOutput( auto cc = cm::make_unique<cmCustomCommand>();
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, outputs, cc->SetBacktrace(this->DirectoryBacktrace);
byproducts, depends, main_dependency, implicit_depends, commandLines, cc->SetOutputs(outputs);
comment, workingDir, replace, escapeOldStyle, uses_terminal, cc->SetByproducts(byproducts);
command_expand_lists, depfile, job_pool, stdPipesUTF8, cmp0116); cc->SetDepends(depends);
cc->SetImplicitDepends(implicit_depends);
cc->SetCommandLines(commandLines);
cc->SetComment(comment);
cc->SetWorkingDirectory(workingDir);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetUsesTerminal(uses_terminal);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetDepfile(depfile);
cc->SetJobPool(job_pool);
cc->SetStdPipesUTF8(stdPipesUTF8);
cc->SetCMP0116Status(cmp0116);
return detail::AddCustomCommandToOutput(*this, cmCommandOrigin::Generator,
main_dependency, std::move(cc),
replace);
} }
cmTarget* cmLocalGenerator::AddUtilityCommand( cmTarget* cmLocalGenerator::AddUtilityCommand(
@@ -1136,10 +1161,21 @@ cmTarget* cmLocalGenerator::AddUtilityCommand(
return target; return target;
} }
detail::AddUtilityCommand( auto cc = cm::make_unique<cmCustomCommand>();
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, target, cc->SetBacktrace(this->DirectoryBacktrace);
workingDir, byproducts, depends, commandLines, escapeOldStyle, comment, cc->SetWorkingDirectory(workingDir);
uses_terminal, command_expand_lists, job_pool, stdPipesUTF8, cmp0116); cc->SetByproducts(byproducts);
cc->SetDepends(depends);
cc->SetCommandLines(commandLines);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetComment(comment);
cc->SetUsesTerminal(uses_terminal);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetJobPool(job_pool);
cc->SetStdPipesUTF8(stdPipesUTF8);
cc->SetCMP0116Status(cmp0116);
detail::AddUtilityCommand(*this, cmCommandOrigin::Generator, target,
std::move(cc));
return target; return target;
} }
@@ -4051,19 +4087,16 @@ std::string ComputeCustomCommandRuleFileName(cmLocalGenerator& lg,
h.HashString(output).substr(0, 16)); h.HashString(output).substr(0, 16));
} }
cmSourceFile* AddCustomCommand( cmSourceFile* AddCustomCommand(cmLocalGenerator& lg, cmCommandOrigin origin,
cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, const std::string& main_dependency,
cmCommandOrigin origin, const std::vector<std::string>& outputs, std::unique_ptr<cmCustomCommand> cc,
const std::vector<std::string>& byproducts, bool replace)
const std::vector<std::string>& depends, const std::string& main_dependency,
const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
const std::string& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116)
{ {
cmMakefile* mf = lg.GetMakefile(); cmMakefile* mf = lg.GetMakefile();
const auto& lfbt = cc->GetBacktrace();
const auto& outputs = cc->GetOutputs();
const auto& byproducts = cc->GetByproducts();
const auto& commandLines = cc->GetCommandLines();
// Choose a source file on which to store the custom command. // Choose a source file on which to store the custom command.
cmSourceFile* file = nullptr; cmSourceFile* file = nullptr;
@@ -4118,34 +4151,18 @@ cmSourceFile* AddCustomCommand(
// Attach the custom command to the file. // Attach the custom command to the file.
if (file) { if (file) {
// Construct a complete list of dependencies. // Construct a complete list of dependencies.
std::vector<std::string> depends2(depends);
if (!main_dependency.empty()) { if (!main_dependency.empty()) {
depends2.push_back(main_dependency); cc->AppendDepends({ main_dependency });
} }
std::unique_ptr<cmCustomCommand> cc = cm::make_unique<cmCustomCommand>();
cc->SetByproducts(byproducts);
cc->SetDepends(std::move(depends2));
cc->SetOutputs(outputs);
cc->SetCommandLines(commandLines);
cc->SetComment(comment);
cc->SetBacktrace(lfbt);
cc->SetWorkingDirectory(workingDir);
cc->SetStdPipesUTF8(stdPipesUTF8);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetEscapeAllowMakeVars(true); cc->SetEscapeAllowMakeVars(true);
cc->SetImplicitDepends(implicit_depends);
cc->SetUsesTerminal(uses_terminal);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetDepfile(depfile);
cc->SetJobPool(job_pool);
cc->SetCMP0116Status(cmp0116);
file->SetCustomCommand(std::move(cc));
lg.AddSourceOutputs(file, outputs, cmLocalGenerator::OutputRole::Primary, lg.AddSourceOutputs(file, outputs, cmLocalGenerator::OutputRole::Primary,
lfbt, origin); lfbt, origin);
lg.AddSourceOutputs(file, byproducts, lg.AddSourceOutputs(file, byproducts,
cmLocalGenerator::OutputRole::Byproduct, lfbt, origin); cmLocalGenerator::OutputRole::Byproduct, lfbt, origin);
file->SetCustomCommand(std::move(cc));
} }
return file; return file;
} }
@@ -4174,68 +4191,39 @@ bool AnyTargetCommandOutputMatches(
} }
namespace detail { namespace detail {
void AddCustomCommandToTarget(cmLocalGenerator& lg, void AddCustomCommandToTarget(cmLocalGenerator& lg, cmCommandOrigin origin,
const cmListFileBacktrace& lfbt, cmTarget* target, cmCustomCommandType type,
cmCommandOrigin origin, cmTarget* target, std::unique_ptr<cmCustomCommand> cc)
const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
cmCustomCommandType type, const char* comment,
const char* workingDir, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile,
const std::string& job_pool,
bool command_expand_lists, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116)
{ {
// Add the command to the appropriate build step for the target. // Add the command to the appropriate build step for the target.
cmCustomCommand cc; cc->SetEscapeAllowMakeVars(true);
cc.SetByproducts(byproducts); cc->SetTarget(target->GetName());
cc.SetDepends(depends);
cc.SetCommandLines(commandLines); lg.AddTargetByproducts(target, cc->GetByproducts(), cc->GetBacktrace(),
cc.SetComment(comment); origin);
cc.SetBacktrace(lfbt);
cc.SetWorkingDirectory(workingDir);
cc.SetStdPipesUTF8(stdPipesUTF8);
cc.SetEscapeOldStyle(escapeOldStyle);
cc.SetEscapeAllowMakeVars(true);
cc.SetUsesTerminal(uses_terminal);
cc.SetCommandExpandLists(command_expand_lists);
cc.SetDepfile(depfile);
cc.SetJobPool(job_pool);
cc.SetCMP0116Status(cmp0116);
cc.SetTarget(target->GetName());
switch (type) { switch (type) {
case cmCustomCommandType::PRE_BUILD: case cmCustomCommandType::PRE_BUILD:
target->AddPreBuildCommand(std::move(cc)); target->AddPreBuildCommand(std::move(*cc));
break; break;
case cmCustomCommandType::PRE_LINK: case cmCustomCommandType::PRE_LINK:
target->AddPreLinkCommand(std::move(cc)); target->AddPreLinkCommand(std::move(*cc));
break; break;
case cmCustomCommandType::POST_BUILD: case cmCustomCommandType::POST_BUILD:
target->AddPostBuildCommand(std::move(cc)); target->AddPostBuildCommand(std::move(*cc));
break; break;
} }
lg.AddTargetByproducts(target, byproducts, lfbt, origin); cc.reset();
} }
cmSourceFile* AddCustomCommandToOutput( cmSourceFile* AddCustomCommandToOutput(cmLocalGenerator& lg,
cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, cmCommandOrigin origin,
cmCommandOrigin origin, const std::vector<std::string>& outputs, const std::string& main_dependency,
const std::vector<std::string>& byproducts, std::unique_ptr<cmCustomCommand> cc,
const std::vector<std::string>& depends, const std::string& main_dependency, bool replace)
const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
const std::string& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116)
{ {
return AddCustomCommand(lg, lfbt, origin, outputs, byproducts, depends, return AddCustomCommand(lg, origin, main_dependency, std::move(cc), replace);
main_dependency, implicit_depends, commandLines,
comment, workingDir, replace, escapeOldStyle,
uses_terminal, command_expand_lists, depfile,
job_pool, stdPipesUTF8, cmp0116);
} }
void AppendCustomCommandToOutput(cmLocalGenerator& lg, void AppendCustomCommandToOutput(cmLocalGenerator& lg,
@@ -4278,33 +4266,27 @@ void AppendCustomCommandToOutput(cmLocalGenerator& lg,
lfbt); lfbt);
} }
void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, void AddUtilityCommand(cmLocalGenerator& lg, cmCommandOrigin origin,
cmCommandOrigin origin, cmTarget* target, cmTarget* target, std::unique_ptr<cmCustomCommand> cc)
const char* workingDir,
const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
bool escapeOldStyle, const char* comment,
bool uses_terminal, bool command_expand_lists,
const std::string& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116)
{ {
// They might be moved away
auto byproducts = cc->GetByproducts();
auto lfbt = cc->GetBacktrace();
// Use an empty comment to avoid generation of default comment. // Use an empty comment to avoid generation of default comment.
if (!comment) { if (!cc->GetComment()) {
comment = ""; cc->SetComment("");
} }
// Create the generated symbolic output name of the utility target. // Create the generated symbolic output name of the utility target.
std::string output = std::string output =
lg.CreateUtilityOutput(target->GetName(), byproducts, lfbt); lg.CreateUtilityOutput(target->GetName(), byproducts, lfbt);
cc->SetOutputs(output);
std::string no_main_dependency; std::string no_main_dependency;
cmImplicitDependsList no_implicit_depends; cmSourceFile* rule =
cmSourceFile* rule = AddCustomCommand( AddCustomCommand(lg, origin, no_main_dependency, std::move(cc),
lg, lfbt, origin, { output }, byproducts, depends, no_main_dependency, /*replace=*/false);
no_implicit_depends, commandLines, comment, workingDir,
/*replace=*/false, escapeOldStyle, uses_terminal, command_expand_lists,
/*depfile=*/"", job_pool, stdPipesUTF8, cmp0116);
if (rule) { if (rule) {
lg.AddTargetByproducts(target, byproducts, lfbt, origin); lg.AddTargetByproducts(target, byproducts, lfbt, origin);
} }

View File

@@ -713,30 +713,15 @@ bool cmLocalGeneratorCheckObjectName(std::string& objName,
#endif #endif
namespace detail { namespace detail {
void AddCustomCommandToTarget(cmLocalGenerator& lg, void AddCustomCommandToTarget(cmLocalGenerator& lg, cmCommandOrigin origin,
const cmListFileBacktrace& lfbt, cmTarget* target, cmCustomCommandType type,
cmCommandOrigin origin, cmTarget* target, std::unique_ptr<cmCustomCommand> cc);
const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
cmCustomCommandType type, const char* comment,
const char* workingDir, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile,
const std::string& job_pool,
bool command_expand_lists, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116);
cmSourceFile* AddCustomCommandToOutput( cmSourceFile* AddCustomCommandToOutput(cmLocalGenerator& lg,
cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, cmCommandOrigin origin,
cmCommandOrigin origin, const std::vector<std::string>& outputs, const std::string& main_dependency,
const std::vector<std::string>& byproducts, std::unique_ptr<cmCustomCommand> cc,
const std::vector<std::string>& depends, const std::string& main_dependency, bool replace);
const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
const std::string& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116);
void AppendCustomCommandToOutput(cmLocalGenerator& lg, void AppendCustomCommandToOutput(cmLocalGenerator& lg,
const cmListFileBacktrace& lfbt, const cmListFileBacktrace& lfbt,
@@ -745,16 +730,8 @@ void AppendCustomCommandToOutput(cmLocalGenerator& lg,
const cmImplicitDependsList& implicit_depends, const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines); const cmCustomCommandLines& commandLines);
void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, void AddUtilityCommand(cmLocalGenerator& lg, cmCommandOrigin origin,
cmCommandOrigin origin, cmTarget* target, cmTarget* target, std::unique_ptr<cmCustomCommand> cc);
const char* workingDir,
const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
bool escapeOldStyle, const char* comment,
bool uses_terminal, bool command_expand_lists,
const std::string& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116);
std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target); std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target);
std::vector<std::string> ComputeISPCExtraObjects( std::vector<std::string> ComputeISPCExtraObjects(

View File

@@ -900,7 +900,12 @@ void cmMakefile::AddGeneratorAction(GeneratorAction&& action)
void cmMakefile::GeneratorAction::operator()(cmLocalGenerator& lg, void cmMakefile::GeneratorAction::operator()(cmLocalGenerator& lg,
const cmListFileBacktrace& lfbt) const cmListFileBacktrace& lfbt)
{ {
Action(lg, lfbt); if (cc) {
CCAction(lg, lfbt, std::move(cc));
} else {
assert(Action);
Action(lg, lfbt);
}
} }
void cmMakefile::DoGenerate(cmLocalGenerator& lg) void cmMakefile::DoGenerate(cmLocalGenerator& lg)
@@ -962,19 +967,6 @@ private:
cmListFileBacktrace& Backtrace; cmListFileBacktrace& Backtrace;
cmListFileBacktrace Previous; cmListFileBacktrace Previous;
}; };
cm::optional<std::string> MakeOptionalString(const char* str)
{
if (str) {
return str;
}
return cm::nullopt;
}
const char* GetCStrOrNull(const cm::optional<std::string>& str)
{
return str ? str->c_str() : nullptr;
}
} }
bool cmMakefile::ValidateCustomCommand( bool cmMakefile::ValidateCustomCommand(
@@ -1082,19 +1074,29 @@ cmTarget* cmMakefile::AddCustomCommandToTarget(
auto cmp0116 = this->GetPolicyStatus(cmPolicies::CMP0116); auto cmp0116 = this->GetPolicyStatus(cmPolicies::CMP0116);
// Strings could be moved into the callback function with C++14. auto cc = cm::make_unique<cmCustomCommand>();
cm::optional<std::string> commentStr = MakeOptionalString(comment); cc->SetByproducts(byproducts);
cm::optional<std::string> workingStr = MakeOptionalString(workingDir); cc->SetDepends(depends);
cc->SetCommandLines(commandLines);
cc->SetComment(comment);
cc->SetWorkingDirectory(workingDir);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetUsesTerminal(uses_terminal);
cc->SetDepfile(depfile);
cc->SetJobPool(job_pool);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetStdPipesUTF8(stdPipesUTF8);
cc->SetCMP0116Status(cmp0116);
// Dispatch command creation to allow generator expressions in outputs. // Dispatch command creation to allow generator expressions in outputs.
this->AddGeneratorAction( this->AddGeneratorAction(
[=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) { std::move(cc),
[=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
std::unique_ptr<cmCustomCommand> tcc) {
BacktraceGuard guard(this->Backtrace, lfbt); BacktraceGuard guard(this->Backtrace, lfbt);
detail::AddCustomCommandToTarget( tcc->SetBacktrace(lfbt);
lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends, detail::AddCustomCommandToTarget(lg, cmCommandOrigin::Project, t, type,
commandLines, type, GetCStrOrNull(commentStr), std::move(tcc));
GetCStrOrNull(workingStr), escapeOldStyle, uses_terminal, depfile,
job_pool, command_expand_lists, stdPipesUTF8, cmp0116);
}); });
return t; return t;
@@ -1143,20 +1145,32 @@ void cmMakefile::AddCustomCommandToOutput(
auto cmp0116 = this->GetPolicyStatus(cmPolicies::CMP0116); auto cmp0116 = this->GetPolicyStatus(cmPolicies::CMP0116);
// Strings could be moved into the callback function with C++14. auto cc = cm::make_unique<cmCustomCommand>();
cm::optional<std::string> commentStr = MakeOptionalString(comment); cc->SetOutputs(outputs);
cm::optional<std::string> workingStr = MakeOptionalString(workingDir); cc->SetByproducts(byproducts);
cc->SetDepends(depends);
cc->SetImplicitDepends(implicit_depends);
cc->SetCommandLines(commandLines);
cc->SetComment(comment);
cc->SetWorkingDirectory(workingDir);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetUsesTerminal(uses_terminal);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetDepfile(depfile);
cc->SetJobPool(job_pool);
cc->SetStdPipesUTF8(stdPipesUTF8);
cc->SetCMP0116Status(cmp0116);
// Dispatch command creation to allow generator expressions in outputs. // Dispatch command creation to allow generator expressions in outputs.
this->AddGeneratorAction( this->AddGeneratorAction(
[=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) { std::move(cc),
[=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
std::unique_ptr<cmCustomCommand> tcc) {
BacktraceGuard guard(this->Backtrace, lfbt); BacktraceGuard guard(this->Backtrace, lfbt);
tcc->SetBacktrace(lfbt);
cmSourceFile* sf = detail::AddCustomCommandToOutput( cmSourceFile* sf = detail::AddCustomCommandToOutput(
lg, lfbt, cmCommandOrigin::Project, outputs, byproducts, depends, lg, cmCommandOrigin::Project, main_dependency, std::move(tcc),
main_dependency, implicit_depends, commandLines, replace);
GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace,
escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool,
stdPipesUTF8, cmp0116);
if (callback && sf) { if (callback && sf) {
callback(sf); callback(sf);
} }
@@ -1264,19 +1278,28 @@ cmTarget* cmMakefile::AddUtilityCommand(
auto cmp0116 = this->GetPolicyStatus(cmPolicies::CMP0116); auto cmp0116 = this->GetPolicyStatus(cmPolicies::CMP0116);
// Strings could be moved into the callback function with C++14. auto cc = cm::make_unique<cmCustomCommand>();
cm::optional<std::string> commentStr = MakeOptionalString(comment); cc->SetWorkingDirectory(workingDir);
cm::optional<std::string> workingStr = MakeOptionalString(workingDir); cc->SetByproducts(byproducts);
cc->SetDepends(depends);
cc->SetCommandLines(commandLines);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetComment(comment);
cc->SetUsesTerminal(uses_terminal);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetJobPool(job_pool);
cc->SetStdPipesUTF8(stdPipesUTF8);
cc->SetCMP0116Status(cmp0116);
// Dispatch command creation to allow generator expressions in outputs. // Dispatch command creation to allow generator expressions in outputs.
this->AddGeneratorAction( this->AddGeneratorAction(
[=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) { std::move(cc),
[=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
std::unique_ptr<cmCustomCommand> tcc) {
BacktraceGuard guard(this->Backtrace, lfbt); BacktraceGuard guard(this->Backtrace, lfbt);
detail::AddUtilityCommand( tcc->SetBacktrace(lfbt);
lg, lfbt, cmCommandOrigin::Project, target, GetCStrOrNull(workingStr), detail::AddUtilityCommand(lg, cmCommandOrigin::Project, target,
byproducts, depends, commandLines, escapeOldStyle, std::move(tcc));
GetCStrOrNull(commentStr), uses_terminal, command_expand_lists,
job_pool, stdPipesUTF8, cmp0116);
}); });
return target; return target;

View File

@@ -24,6 +24,7 @@
#include "cm_sys_stat.h" #include "cm_sys_stat.h"
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandTypes.h" #include "cmCustomCommandTypes.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
#include "cmMessageType.h" #include "cmMessageType.h"
@@ -50,7 +51,6 @@ class cmExportBuildFileGenerator;
class cmFunctionBlocker; class cmFunctionBlocker;
class cmGeneratorExpressionEvaluationFile; class cmGeneratorExpressionEvaluationFile;
class cmGlobalGenerator; class cmGlobalGenerator;
class cmImplicitDependsList;
class cmInstallGenerator; class cmInstallGenerator;
class cmLocalGenerator; class cmLocalGenerator;
class cmMessenger; class cmMessenger;
@@ -144,6 +144,9 @@ public:
{ {
using ActionT = using ActionT =
std::function<void(cmLocalGenerator&, const cmListFileBacktrace&)>; std::function<void(cmLocalGenerator&, const cmListFileBacktrace&)>;
using CCActionT =
std::function<void(cmLocalGenerator&, const cmListFileBacktrace&,
std::unique_ptr<cmCustomCommand> cc)>;
public: public:
GeneratorAction(ActionT&& action) GeneratorAction(ActionT&& action)
@@ -151,10 +154,20 @@ public:
{ {
} }
GeneratorAction(std::unique_ptr<cmCustomCommand> tcc, CCActionT&& action)
: CCAction(std::move(action))
, cc(std::move(tcc))
{
}
void operator()(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt); void operator()(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt);
private: private:
ActionT Action; ActionT Action;
// FIXME: Use std::variant
CCActionT CCAction;
std::unique_ptr<cmCustomCommand> cc;
}; };
/** /**