Index: tools/gn/ninja_writer.cc |
diff --git a/tools/gn/ninja_writer.cc b/tools/gn/ninja_writer.cc |
index 23b9a72f8f913ff08f1b2ca1b10e430711106795..c8c8c9dfc29d6d2538e6625639d816b544d12ead 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) |
@@ -30,6 +31,12 @@ bool NinjaWriter::RunAndWriteFiles(const BuildSettings* build_settings, |
std::vector<const Target*> default_targets; |
if (!writer.WriteToolchains(&all_settings, &default_targets, err)) |
return false; |
+ |
+ // Sort targets so that they are in a deterministic order. |
M-A Ruel
2015/12/07 15:09:50
I'd prefer WriteToolchains() to return a sorted li
Zachary Forman
2015/12/08 09:40:43
This is a good idea. It'll improve speed (as the w
|
+ std::sort( |
+ default_targets.begin(), default_targets.end(), |
+ [](const Target* a, const Target* b) { return a->label() < b->label(); }); |
+ |
return writer.WriteRootBuildfiles(all_settings, default_targets, err); |
} |
@@ -70,13 +77,14 @@ bool NinjaWriter::WriteToolchains(std::vector<const Settings*>* all_settings, |
// 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 (CategorizedMap::iterator i = categorized.begin(); i != categorized.end(); |
M-A Ruel
2015/12/07 15:09:50
If you use a set above, you can switch to an enume
Zachary Forman
2015/12/08 09:40:42
Have done.
|
+ ++i) { |
const Settings* settings = |
builder_->loader()->GetToolchainSettings(i->first); |
const Toolchain* toolchain = builder_->GetToolchain(i->first); |
all_settings->push_back(settings); |
+ |
if (!NinjaToolchainWriter::RunAndWriteFile(settings, toolchain, |
i->second)) { |
Err(Location(), |