Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Unified Diff: tools/gn/ninja_build_writer.cc

Issue 1265793002: patch from petermayo to fix GN dependency regeneration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not escape paths in build.ninja.d Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/function_write_file.cc ('k') | tools/gn/scheduler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..500f05575bae02e57ec87ca369fc3836ad625073 100644
--- a/tools/gn/ninja_build_writer.cc
+++ b/tools/gn/ninja_build_writer.cc
@@ -77,6 +77,15 @@ std::string GetSelfInvocationCommand(const BuildSettings* build_settings) {
#endif
}
+void WriteAnotherFile(std::ostream& out, const base::FilePath& name,
+ EscapingMode mode) {
+ EscapeOptions path_escaping;
+ path_escaping.mode = mode;
+
+ out << " ";
+ EscapeStringToStream(out, FilePathToUTF8(name), path_escaping);
+}
+
} // namespace
NinjaBuildWriter::NinjaBuildWriter(
@@ -143,10 +152,20 @@ 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,
+ // 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)
+ WriteAnotherFile(out_, build_settings_->GetFullPath(written_file),
+ ESCAPE_NINJA_COMMAND);
- // This rule will regenerate the ninja files when any input file has changed.
- out_ << "build build.ninja: gn\n"
+ out_ << ": gn\n"
<< " generator = 1\n"
<< " depfile = build.ninja.d\n";
@@ -158,12 +177,12 @@ void NinjaBuildWriter::WriteNinjaRules() {
std::vector<base::FilePath> input_files;
g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files);
for (const auto& input_file : input_files)
- dep_out_ << " " << FilePathToUTF8(input_file);
+ WriteAnotherFile(dep_out_, input_file, ESCAPE_NONE);
// Other files read by the build.
std::vector<base::FilePath> other_files = g_scheduler->GetGenDependencies();
for (const auto& other_file : other_files)
- dep_out_ << " " << FilePathToUTF8(other_file);
+ WriteAnotherFile(dep_out_, other_file, ESCAPE_NONE);
out_ << std::endl;
}
« no previous file with comments | « tools/gn/function_write_file.cc ('k') | tools/gn/scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698