summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2024-02-14 18:42:18 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2024-02-15 04:01:25 (GMT)
commita7424b636b28ce0b6f9d7156dd3e1fe0e487f643 (patch)
tree4bce83873856758a4445c40b4369503a8e4cee68
parente24eecfc33ba5678bed2bbc24cf85bdea0a98de8 (diff)
downloadCMake-a7424b636b28ce0b6f9d7156dd3e1fe0e487f643.zip
CMake-a7424b636b28ce0b6f9d7156dd3e1fe0e487f643.tar.gz
CMake-a7424b636b28ce0b6f9d7156dd3e1fe0e487f643.tar.bz2
Ninja: make the collator rule use `restat = 1`
This avoids rebuilds when the module metadata does not change.
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx2
-rw-r--r--Source/cmNinjaTargetGenerator.cxx5
2 files changed, 7 insertions, 0 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 22fd90d..4fa5032 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -2763,6 +2763,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
// `cmNinjaTargetGenerator::ExportObjectCompileCommand` to generate the
// corresponding file path.
cmGeneratedFileStream mmf(cmStrCat(object.PrimaryOutput, ".modmap"));
+ mmf.SetCopyIfDifferent(true);
mmf << mm;
}
@@ -2852,6 +2853,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
}
cmGeneratedFileStream tmf(target_mods_file);
+ tmf.SetCopyIfDifferent(true);
tmf << target_module_info;
cmDyndepMetadataCallbacks cb;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 9c75cd6..58248fc 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -814,6 +814,11 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
// dyndep rules
rule.RspFile = "$out.rsp";
rule.RspContent = "$in";
+ // Ninja's collator writes all outputs using `cmGeneratedFileStream`, so
+ // they are only updated if contents actually change. Avoid running
+ // dependent jobs if the contents don't change by telling `ninja` to check
+ // the timestamp again.
+ rule.Restat = "1";
// Run CMake dependency scanner on the source file (using the preprocessed
// source if that was performed).