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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 << " generator = 1\n" | 187 << " generator = 1\n" |
188 << " depfile = build.ninja.d\n"; | 188 << " depfile = build.ninja.d\n"; |
189 | 189 |
190 // 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 |
191 // 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 |
192 // 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, |
193 // missing files are ignored. | 193 // missing files are ignored. |
194 dep_out_ << "build.ninja:"; | 194 dep_out_ << "build.ninja:"; |
195 std::vector<base::FilePath> input_files; | 195 std::vector<base::FilePath> input_files; |
196 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files); | 196 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files); |
197 for (const auto& input_file : input_files) | 197 |
198 dep_out_ << " " << FilePathToUTF8(input_file); | 198 // Keep the files sorted to ensure output is deterministic. |
mithro-old
2015/12/03 05:20:31
If you are assuming the input is sorted here, it p
Zachary Forman
2015/12/03 07:27:02
Poorly phrased - we place the filepaths into a set
| |
199 std::set<base::FilePath> file_set(input_files.begin(), input_files.end()); | |
199 | 200 |
200 // Other files read by the build. | 201 // Other files read by the build. |
201 std::vector<base::FilePath> other_files = g_scheduler->GetGenDependencies(); | 202 input_files = g_scheduler->GetGenDependencies(); |
202 for (const auto& other_file : other_files) | 203 |
203 dep_out_ << " " << FilePathToUTF8(other_file); | 204 file_set.insert(input_files.begin(), input_files.end()); |
205 | |
206 for (const auto& input_file : file_set) | |
207 dep_out_ << " " << FilePathToUTF8(input_file); | |
204 | 208 |
205 out_ << std::endl; | 209 out_ << std::endl; |
206 } | 210 } |
207 | 211 |
208 void NinjaBuildWriter::WriteLinkPool() { | 212 void NinjaBuildWriter::WriteLinkPool() { |
209 out_ << "pool link_pool\n" | 213 out_ << "pool link_pool\n" |
210 << " depth = " << default_toolchain_->concurrent_links() << std::endl | 214 << " depth = " << default_toolchain_->concurrent_links() << std::endl |
211 << std::endl; | 215 << std::endl; |
212 } | 216 } |
213 | 217 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 EscapeOptions ninja_escape; | 352 EscapeOptions ninja_escape; |
349 ninja_escape.mode = ESCAPE_NINJA; | 353 ninja_escape.mode = ESCAPE_NINJA; |
350 | 354 |
351 // Escape for special chars Ninja will handle. | 355 // Escape for special chars Ninja will handle. |
352 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); | 356 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); |
353 | 357 |
354 out_ << "build " << escaped << ": phony "; | 358 out_ << "build " << escaped << ": phony "; |
355 path_output_.WriteFile(out_, target_file); | 359 path_output_.WriteFile(out_, target_file); |
356 out_ << std::endl; | 360 out_ << std::endl; |
357 } | 361 } |
OLD | NEW |