Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Unified Diff: tools/gn/ninja_build_writer.cc

Issue 1494883002: GN: Makes GN output deterministic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code delousing Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/ninja_target_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_build_writer.cc
diff --git a/tools/gn/ninja_build_writer.cc b/tools/gn/ninja_build_writer.cc
index 50638fbb7876819438dea2b6dbe659779da72731..395732e1571db363390c2294bfab04673bdcff09 100644
--- a/tools/gn/ninja_build_writer.cc
+++ b/tools/gn/ninja_build_writer.cc
@@ -194,12 +194,16 @@ void NinjaBuildWriter::WriteNinjaRules() {
dep_out_ << "build.ninja:";
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);
// Other files read by the build.
std::vector<base::FilePath> other_files = g_scheduler->GetGenDependencies();
- for (const auto& other_file : other_files)
+
+ // Sort the input files to order them deterministically.
+ // Additionally, remove duplicate filepaths that seem to creep in.
+ std::set<base::FilePath> fileset(input_files.begin(), input_files.end());
+ fileset.insert(other_files.begin(), other_files.end());
+
+ for (const auto& other_file : fileset)
dep_out_ << " " << FilePathToUTF8(other_file);
out_ << std::endl;
« no previous file with comments | « no previous file | tools/gn/ninja_target_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698