| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/gn/ninja_build_writer.h" | 5 #include "tools/gn/ninja_build_writer.h" |
| 6 | 6 |
| 7 #include <fstream> | 7 #include <fstream> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 173 } |
| 174 | 174 |
| 175 NinjaBuildWriter gen(build_settings, all_settings, default_toolchain, | 175 NinjaBuildWriter gen(build_settings, all_settings, default_toolchain, |
| 176 default_toolchain_targets, file, depfile); | 176 default_toolchain_targets, file, depfile); |
| 177 return gen.Run(err); | 177 return gen.Run(err); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void NinjaBuildWriter::WriteNinjaRules() { | 180 void NinjaBuildWriter::WriteNinjaRules() { |
| 181 out_ << "rule gn\n"; | 181 out_ << "rule gn\n"; |
| 182 out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n"; | 182 out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n"; |
| 183 out_ << " description = Regenerating ninja files\n"; | 183 out_ << " description = Regenerating ninja files\n\n"; |
| 184 out_ << " restat = 1\n\n"; | |
| 185 | 184 |
| 186 // This rule will regenerate the ninja files when any input file has changed, | 185 // This rule will regenerate the ninja files when any input file has changed. |
| 187 // or is missing. | 186 out_ << "build build.ninja: gn\n" |
| 188 out_ << "build build.ninja"; | |
| 189 | |
| 190 // Other files read by the build. | |
| 191 EscapeOptions path_escaping; | |
| 192 path_escaping.mode = ESCAPE_NINJA_COMMAND; | |
| 193 std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles(); | |
| 194 for (const auto& written_file : written_files) | |
| 195 out_ << " " << EscapeString(RebasePath(written_file.value(), | |
| 196 build_settings_->build_dir(), build_settings_->root_path_utf8()), | |
| 197 path_escaping, nullptr); | |
| 198 | |
| 199 out_ << ": gn\n" | |
| 200 << " generator = 1\n" | 187 << " generator = 1\n" |
| 201 << " depfile = build.ninja.d\n"; | 188 << " depfile = build.ninja.d\n"; |
| 202 | 189 |
| 203 // Input build files. These go in the ".d" file. If we write them as | 190 // Input build files. These go in the ".d" file. If we write them as |
| 204 // dependencies in the .ninja file itself, ninja will expect the files to | 191 // dependencies in the .ninja file itself, ninja will expect the files to |
| 205 // exist and will error if they don't. When files are listed in a depfile, | 192 // exist and will error if they don't. When files are listed in a depfile, |
| 206 // missing files are ignored. | 193 // missing files are ignored. |
| 207 dep_out_ << "build.ninja:"; | 194 dep_out_ << "build.ninja:"; |
| 208 std::vector<base::FilePath> input_files; | 195 std::vector<base::FilePath> input_files; |
| 209 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files); | 196 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 EscapeOptions ninja_escape; | 348 EscapeOptions ninja_escape; |
| 362 ninja_escape.mode = ESCAPE_NINJA; | 349 ninja_escape.mode = ESCAPE_NINJA; |
| 363 | 350 |
| 364 // Escape for special chars Ninja will handle. | 351 // Escape for special chars Ninja will handle. |
| 365 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); | 352 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); |
| 366 | 353 |
| 367 out_ << "build " << escaped << ": phony "; | 354 out_ << "build " << escaped << ": phony "; |
| 368 path_output_.WriteFile(out_, target_file); | 355 path_output_.WriteFile(out_, target_file); |
| 369 out_ << std::endl; | 356 out_ << std::endl; |
| 370 } | 357 } |
| OLD | NEW |