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

Unified Diff: tools/gn/ninja_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 | « tools/gn/ninja_target_writer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_writer.cc
diff --git a/tools/gn/ninja_writer.cc b/tools/gn/ninja_writer.cc
index 23b9a72f8f913ff08f1b2ca1b10e430711106795..154f017a435acecad3ca83879901e070b25f20f3 100644
--- a/tools/gn/ninja_writer.cc
+++ b/tools/gn/ninja_writer.cc
@@ -10,6 +10,7 @@
#include "tools/gn/ninja_build_writer.h"
#include "tools/gn/ninja_toolchain_writer.h"
#include "tools/gn/settings.h"
+#include "tools/gn/target.h"
NinjaWriter::NinjaWriter(const BuildSettings* build_settings,
Builder* builder)
@@ -66,19 +67,26 @@ bool NinjaWriter::WriteToolchains(std::vector<const Settings*>* all_settings,
return false;
}
+ for (auto& i : categorized) {
+ // Sort targets so that they are in a deterministic order.
+ std::sort(i.second.begin(), i.second.end(),
+ [](const Target* a, const Target* b) {
+ return a->label() < b->label();
+ });
+ }
+
Label default_label = builder_->loader()->GetDefaultToolchain();
// Write out the toolchain buildfiles, and also accumulate the set of
// all settings and find the list of targets in the default toolchain.
- for (CategorizedMap::const_iterator i = categorized.begin();
- i != categorized.end(); ++i) {
+ for (const auto& i : categorized) {
const Settings* settings =
- builder_->loader()->GetToolchainSettings(i->first);
- const Toolchain* toolchain = builder_->GetToolchain(i->first);
+ builder_->loader()->GetToolchainSettings(i.first);
+ const Toolchain* toolchain = builder_->GetToolchain(i.first);
all_settings->push_back(settings);
- if (!NinjaToolchainWriter::RunAndWriteFile(settings, toolchain,
- i->second)) {
+
+ if (!NinjaToolchainWriter::RunAndWriteFile(settings, toolchain, i.second)) {
Err(Location(),
"Couldn't open toolchain buildfile(s) for writing").PrintToStdout();
return false;
« no previous file with comments | « tools/gn/ninja_target_writer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698