Merge topic 'prepare-deferred-custom-command-creation'

5d28e361b7 add_custom_command: Move append functionality into class cmMakefile
4fb29850ad add_custom_command: Refactor setting implicit depends

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3810
This commit is contained in:
Brad King
2019-09-16 14:16:57 +00:00
committed by Kitware Robot
7 changed files with 65 additions and 57 deletions

View File

@@ -12,7 +12,6 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
@@ -50,7 +49,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
bool uses_terminal = false;
bool command_expand_lists = false;
std::string implicit_depends_lang;
cmCustomCommand::ImplicitDependsList implicit_depends;
cmImplicitDependsList implicit_depends;
// Accumulate one command line at a time.
cmCustomCommandLine currentLine;
@@ -316,14 +315,9 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
// Check for an append request.
if (append) {
// Lookup an existing command.
if (cmSourceFile* sf = mf.GetSourceFileWithOutput(output[0])) {
if (cmCustomCommand* cc = sf->GetCustomCommand()) {
cc->AppendCommands(commandLines);
cc->AppendDepends(depends);
cc->AppendImplicitDepends(implicit_depends);
return true;
}
if (mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends,
commandLines)) {
return true;
}
// No command for this output exists.
@@ -350,28 +344,10 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
job_pool, command_expand_lists);
} else if (target.empty()) {
// Target is empty, use the output.
mf.AddCustomCommandToOutput(output, byproducts, depends, main_dependency,
commandLines, comment, working.c_str(), false,
escapeOldStyle, uses_terminal,
command_expand_lists, depfile, job_pool);
// Add implicit dependency scanning requests if any were given.
if (!implicit_depends.empty()) {
bool okay = false;
if (cmSourceFile* sf = mf.GetSourceFileWithOutput(output[0])) {
if (cmCustomCommand* cc = sf->GetCustomCommand()) {
okay = true;
cc->SetImplicitDepends(implicit_depends);
}
}
if (!okay) {
std::ostringstream e;
e << "could not locate source file with a custom command producing \""
<< output[0] << "\" even though this command tried to create it!";
status.SetError(e.str());
return false;
}
}
mf.AddCustomCommandToOutput(
output, byproducts, depends, main_dependency, implicit_depends,
commandLines, comment, working.c_str(), false, escapeOldStyle,
uses_terminal, command_expand_lists, depfile, job_pool);
} else if (!byproducts.empty()) {
status.SetError("BYPRODUCTS may not be specified with SOURCE signatures");
return false;