cmNinjaNormalTargetGenerator: Factor out build event byproduct collection

This was left out of commit 68e5f92cad (cmGlobalNinjaGenerator: Factor
out custom command output collection, 2021-05-18).
This commit is contained in:
Brad King
2021-05-20 16:52:54 -04:00
parent 18408c0b88
commit 48471cfd18
+10 -9
View File
@@ -1195,7 +1195,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
} }
} }
cmNinjaDeps byproducts; cmGlobalNinjaGenerator::CCOutputs byproducts(this->GetGlobalGenerator());
if (!tgtNames.ImportLibrary.empty()) { if (!tgtNames.ImportLibrary.empty()) {
const std::string impLibPath = localGen.ConvertToOutputFormat( const std::string impLibPath = localGen.ConvertToOutputFormat(
@@ -1203,7 +1203,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
vars["TARGET_IMPLIB"] = impLibPath; vars["TARGET_IMPLIB"] = impLibPath;
this->EnsureParentDirectoryExists(impLibPath); this->EnsureParentDirectoryExists(impLibPath);
if (gt->HasImportLibrary(config)) { if (gt->HasImportLibrary(config)) {
byproducts.push_back(targetOutputImplib); // Some linkers may update a binary without touching its import lib.
byproducts.ExplicitOuts.emplace_back(targetOutputImplib);
if (firstForConfig) { if (firstForConfig) {
globalGen->GetByproductsForCleanTarget(config).push_back( globalGen->GetByproductsForCleanTarget(config).push_back(
targetOutputImplib); targetOutputImplib);
@@ -1261,8 +1262,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
true, config); true, config);
localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]); localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
std::vector<std::string> const& ccByproducts = ccg.GetByproducts(); std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
std::transform(ccByproducts.begin(), ccByproducts.end(), byproducts.Add(ccByproducts);
std::back_inserter(byproducts), this->MapToNinjaPath());
std::transform( std::transform(
ccByproducts.begin(), ccByproducts.end(), ccByproducts.begin(), ccByproducts.end(),
std::back_inserter(globalGen->GetByproductsForCleanTarget()), std::back_inserter(globalGen->GetByproductsForCleanTarget()),
@@ -1382,12 +1382,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
} }
// Ninja should restat after linking if and only if there are byproducts. // Ninja should restat after linking if and only if there are byproducts.
vars["RESTAT"] = byproducts.empty() ? "" : "1"; vars["RESTAT"] = byproducts.ExplicitOuts.empty() ? "" : "1";
for (std::string const& o : byproducts) { linkBuild.Outputs.reserve(linkBuild.Outputs.size() +
globalGen->SeenCustomCommandOutput(o); byproducts.ExplicitOuts.size());
linkBuild.Outputs.push_back(o); std::move(byproducts.ExplicitOuts.begin(), byproducts.ExplicitOuts.end(),
} std::back_inserter(linkBuild.Outputs));
linkBuild.WorkDirOuts = std::move(byproducts.WorkDirOuts);
// Write the build statement for this target. // Write the build statement for this target.
bool usedResponseFile = false; bool usedResponseFile = false;