Просмотр исходного кода

Ninja: make the collator rule use `restat = 1`

This avoids rebuilds when the module metadata does not change.
Ben Boeckel 1 год назад
Родитель
Сommit
a7424b636b
2 измененных файлов с 7 добавлено и 0 удалено
  1. 2 0
      Source/cmGlobalNinjaGenerator.cxx
  2. 5 0
      Source/cmNinjaTargetGenerator.cxx

+ 2 - 0
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;

+ 5 - 0
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).