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

Unified Diff: tools/gn/ninja_toolchain_writer.cc

Issue 1494883002: GN: Makes GN output deterministic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaked some comments for clarity 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_toolchain_writer.cc
diff --git a/tools/gn/ninja_toolchain_writer.cc b/tools/gn/ninja_toolchain_writer.cc
index e7459ebb3cfa2ede1e0d5303aedfdf0b36e134b2..f33fec065c8bd83c2b318d57d362d3e54d63f5d8 100644
--- a/tools/gn/ninja_toolchain_writer.cc
+++ b/tools/gn/ninja_toolchain_writer.cc
@@ -49,7 +49,7 @@ void NinjaToolchainWriter::Run() {
bool NinjaToolchainWriter::RunAndWriteFile(
const Settings* settings,
const Toolchain* toolchain,
- const std::vector<const Target*>& targets) {
+ std::vector<const Target*>& targets) {
base::FilePath ninja_file(settings->build_settings()->GetFullPath(
GetNinjaFileForToolchain(settings)));
ScopedTrace trace(TraceItem::TRACE_FILE_WRITE, FilePathToUTF8(ninja_file));
@@ -62,6 +62,11 @@ bool NinjaToolchainWriter::RunAndWriteFile(
if (file.fail())
return false;
+ // Sort targets so that they are in a deterministic order.
M-A Ruel 2015/12/07 15:09:50 I'd still prefer: DCHECK( std::is_sorted(targe
Zachary Forman 2015/12/08 09:40:42 I've followed your advice here and effectively rem
+ std::sort(
+ targets.begin(), targets.end(),
+ [](const Target* a, const Target* b) { return a->label() < b->label(); });
+
NinjaToolchainWriter gen(settings, toolchain, targets, file);
gen.Run();
return true;

Powered by Google App Engine
This is Rietveld 408576698