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

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: Moves sort into ninja_toolchain_writer.cc for consistency 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
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..67c2c87781814adf176e3bbe77d06a8903c6456c 100644
--- a/tools/gn/ninja_build_writer.cc
+++ b/tools/gn/ninja_build_writer.cc
@@ -194,13 +194,18 @@ 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);
+
+ // Put the files into a set so that the output is sorted and hence
M-A Ruel 2015/12/07 00:20:16 Why not just std::sort(input_files.begin(), input_
Zachary Forman 2015/12/07 03:18:17 Interestingly, the two vectors seem to contain a n
+ // deterministic.
+ std::set<base::FilePath> file_set(input_files.begin(), input_files.end());
// Other files read by the build.
- std::vector<base::FilePath> other_files = g_scheduler->GetGenDependencies();
- for (const auto& other_file : other_files)
- dep_out_ << " " << FilePathToUTF8(other_file);
+ input_files = g_scheduler->GetGenDependencies();
+
+ file_set.insert(input_files.begin(), input_files.end());
+
+ for (const auto& input_file : file_set)
+ dep_out_ << " " << FilePathToUTF8(input_file);
out_ << std::endl;
}

Powered by Google App Engine
This is Rietveld 408576698