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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 NinjaBuildWriter gen(build_settings, all_settings, default_toolchain, | 138 NinjaBuildWriter gen(build_settings, all_settings, default_toolchain, |
139 default_toolchain_targets, file, depfile); | 139 default_toolchain_targets, file, depfile); |
140 return gen.Run(err); | 140 return gen.Run(err); |
141 } | 141 } |
142 | 142 |
143 void NinjaBuildWriter::WriteNinjaRules() { | 143 void NinjaBuildWriter::WriteNinjaRules() { |
144 out_ << "rule gn\n"; | 144 out_ << "rule gn\n"; |
145 out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n"; | 145 out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n"; |
146 out_ << " description = Regenerating ninja files\n"; | 146 out_ << " description = Regenerating ninja files\n\n"; |
147 out_ << " restat = 1\n\n"; | |
148 | 147 |
149 // This rule will regenerate the ninja files when any input file has changed, | 148 // This rule will regenerate the ninja files when any input file has changed. |
150 // or is missing. | 149 out_ << "build build.ninja: gn\n" |
151 out_ << "build build.ninja"; | |
152 | |
153 // Other files read by the build. | |
154 std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles(); | |
155 for (const auto& written_file : written_files) | |
156 out_ << " " << FilePathToUTF8(build_settings_->GetFullPath(written_file)); | |
157 | |
158 out_ << ": gn\n" | |
159 << " generator = 1\n" | 150 << " generator = 1\n" |
160 << " depfile = build.ninja.d\n"; | 151 << " depfile = build.ninja.d\n"; |
161 | 152 |
162 // Input build files. These go in the ".d" file. If we write them as | 153 // Input build files. These go in the ".d" file. If we write them as |
163 // dependencies in the .ninja file itself, ninja will expect the files to | 154 // dependencies in the .ninja file itself, ninja will expect the files to |
164 // exist and will error if they don't. When files are listed in a depfile, | 155 // exist and will error if they don't. When files are listed in a depfile, |
165 // missing files are ignored. | 156 // missing files are ignored. |
166 dep_out_ << "build.ninja:"; | 157 dep_out_ << "build.ninja:"; |
167 std::vector<base::FilePath> input_files; | 158 std::vector<base::FilePath> input_files; |
168 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files); | 159 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 EscapeOptions ninja_escape; | 313 EscapeOptions ninja_escape; |
323 ninja_escape.mode = ESCAPE_NINJA; | 314 ninja_escape.mode = ESCAPE_NINJA; |
324 | 315 |
325 // Escape for special chars Ninja will handle. | 316 // Escape for special chars Ninja will handle. |
326 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); | 317 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); |
327 | 318 |
328 out_ << "build " << escaped << ": phony "; | 319 out_ << "build " << escaped << ": phony "; |
329 path_output_.WriteFile(out_, target_file); | 320 path_output_.WriteFile(out_, target_file); |
330 out_ << std::endl; | 321 out_ << std::endl; |
331 } | 322 } |
OLD | NEW |