summaryrefslogtreecommitdiff
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-05-18 11:43:11 -0400
committerBrad King <brad.king@kitware.com>2021-05-19 12:07:58 -0400
commit68e5f92cada35068f71a8c46388aeb4eb1383bca (patch)
tree0dc3f33c8c7a3b8bc86d6360b819924b7ddc65df /Source/cmGlobalNinjaGenerator.cxx
parentc5195193d3525dc2b661757e0039486e39b94f27 (diff)
downloadcmake-68e5f92cada35068f71a8c46388aeb4eb1383bca.tar.gz
cmGlobalNinjaGenerator: Factor out custom command output collection
De-duplicate code paths calling ConvertToNinjaPath and SeenCustomCommandOutput on custom command outputs and custom target byproducts.
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 06f7e45e71..64aaf4863e 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -310,11 +310,21 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule()
this->AddRule(rule);
}
+void cmGlobalNinjaGenerator::CCOutputs::Add(
+ std::vector<std::string> const& paths)
+{
+ for (std::string const& path : paths) {
+ std::string out = this->GG->ConvertToNinjaPath(path);
+ this->GG->SeenCustomCommandOutput(out);
+ this->ExplicitOuts.emplace_back(std::move(out));
+ }
+}
+
void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
std::string const& command, std::string const& description,
std::string const& comment, std::string const& depfile,
std::string const& job_pool, bool uses_terminal, bool restat,
- std::string const& config, cmNinjaDeps outputs, cmNinjaDeps explicitDeps,
+ std::string const& config, CCOutputs outputs, cmNinjaDeps explicitDeps,
cmNinjaDeps orderOnlyDeps)
{
this->AddCustomCommandRule();
@@ -330,7 +340,7 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
{
cmNinjaBuild build("CUSTOM_COMMAND");
build.Comment = comment;
- build.Outputs = std::move(outputs);
+ build.Outputs = std::move(outputs.ExplicitOuts);
build.ExplicitDeps = std::move(explicitDeps);
build.OrderOnlyDeps = std::move(orderOnlyDeps);
@@ -1201,6 +1211,8 @@ void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os) const
void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
{
for (auto const& asd : this->AssumedSourceDependencies) {
+ CCOutputs outputs(this);
+ outputs.ExplicitOuts.emplace_back(asd.first);
cmNinjaDeps orderOnlyDeps;
std::copy(asd.second.begin(), asd.second.end(),
std::back_inserter(orderOnlyDeps));
@@ -1209,7 +1221,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
"Assume dependencies for generated source file.",
/*depfile*/ "", /*job_pool*/ "",
/*uses_terminal*/ false,
- /*restat*/ true, std::string(), cmNinjaDeps(1, asd.first), cmNinjaDeps(),
+ /*restat*/ true, std::string(), outputs, cmNinjaDeps(),
std::move(orderOnlyDeps));
}
}