Chromium Code Reviews| 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..dd24a980f0f341e27366a32ef4dfaf0a53206c8d 100644 |
| --- a/tools/gn/ninja_build_writer.cc |
| +++ b/tools/gn/ninja_build_writer.cc |
| @@ -77,6 +77,14 @@ std::string GetSelfInvocationCommand(const BuildSettings* build_settings) { |
| #endif |
| } |
| +void WriteAnotherFile(std::ostream& out, const base::FilePath& name) { |
|
Peter Mayo
2015/07/28 22:37:37
I'm not sure this name is good enough, but I don't
|
| + EscapeOptions path_escaping; |
| + path_escaping.mode = ESCAPE_NINJA_COMMAND; |
|
Peter Mayo
2015/07/28 22:37:37
This mode says it handles one "thing" for ninja, t
|
| + |
| + out << " "; |
|
Dirk Pranke
2015/07/28 22:35:05
I probably would've left line 84 out of this funct
Peter Mayo
2015/07/28 22:41:38
And 178, and 183. That's why I snuck it in here,
Dirk Pranke
2015/07/28 22:43:11
fair enough. Yeah, I understood the naming.
|
| + EscapeStringToStream(out, FilePathToUTF8(name), path_escaping); |
| +} |
| + |
| } // namespace |
| NinjaBuildWriter::NinjaBuildWriter( |
| @@ -143,10 +151,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, |
| + // 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)); |
| - // 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 +175,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); |
| // 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); |
| out_ << std::endl; |
| } |