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

View File

@@ -1195,7 +1195,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
}
}
cmNinjaDeps byproducts;
cmGlobalNinjaGenerator::CCOutputs byproducts(this->GetGlobalGenerator());
if (!tgtNames.ImportLibrary.empty()) {
const std::string impLibPath = localGen.ConvertToOutputFormat(
@@ -1203,7 +1203,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
vars["TARGET_IMPLIB"] = impLibPath;
this->EnsureParentDirectoryExists(impLibPath);
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) {
globalGen->GetByproductsForCleanTarget(config).push_back(
targetOutputImplib);
@@ -1261,8 +1262,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
true, config);
localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
std::transform(ccByproducts.begin(), ccByproducts.end(),
std::back_inserter(byproducts), this->MapToNinjaPath());
byproducts.Add(ccByproducts);
std::transform(
ccByproducts.begin(), ccByproducts.end(),
std::back_inserter(globalGen->GetByproductsForCleanTarget()),
@@ -1382,12 +1382,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
}
// 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) {
globalGen->SeenCustomCommandOutput(o);
linkBuild.Outputs.push_back(o);
}
linkBuild.Outputs.reserve(linkBuild.Outputs.size() +
byproducts.ExplicitOuts.size());
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.
bool usedResponseFile = false;