Index: tools/gn/ninja_build_writer.cc |
diff --git a/tools/gn/ninja_build_writer.cc b/tools/gn/ninja_build_writer.cc |
index 591947d38cae9ca29918c11fc7697625fd56a229..701179f67a5a0e40af65c7a33c92d26898f31d2f 100644 |
--- a/tools/gn/ninja_build_writer.cc |
+++ b/tools/gn/ninja_build_writer.cc |
@@ -143,10 +143,19 @@ bool NinjaBuildWriter::RunAndWriteFile( |
void NinjaBuildWriter::WriteNinjaRules() { |
out_ << "rule gn\n"; |
out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n"; |
- out_ << " description = Regenerating ninja files\n\n"; |
+ out_ << " description = Regenerating ninja files\n"; |
+ out_ << " restat = 1\n\n"; |
- // This rule will regenerate the ninja files when any input file has changed. |
- out_ << "build build.ninja: gn\n" |
+ // This rule will regenerate the ninja files when any input file has changed, |
+ // or is missing. |
+ out_ << "build build.ninja"; |
+ |
+ // Other files read by the build. |
+ std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles(); |
+ for (const auto& written_file : written_files) |
+ out_ << " " << FilePathToUTF8(build_settings_->GetFullPath(written_file)); |
+ |
+ out_ << ": gn\n" |
<< " generator = 1\n" |
<< " depfile = build.ninja.d\n"; |