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) | |
198 dep_out_ << " " << FilePathToUTF8(input_file); | |
199 | 197 |
200 // Other files read by the build. | 198 // Other files read by the build. |
201 std::vector<base::FilePath> other_files = g_scheduler->GetGenDependencies(); | 199 std::vector<base::FilePath> other_files = g_scheduler->GetGenDependencies(); |
202 for (const auto& other_file : other_files) | 200 |
| 201 // Sort the input files to order them deterministically. |
| 202 // Additionally, remove duplicate filepaths that seem to creep in. |
| 203 std::set<base::FilePath> fileset(input_files.begin(), input_files.end()); |
| 204 fileset.insert(other_files.begin(), other_files.end()); |
| 205 |
| 206 for (const auto& other_file : fileset) |
203 dep_out_ << " " << FilePathToUTF8(other_file); | 207 dep_out_ << " " << FilePathToUTF8(other_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 } |
(...skipping 135 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 |