Index: tools/gn/ninja_writer.cc |
diff --git a/tools/gn/ninja_writer.cc b/tools/gn/ninja_writer.cc |
index 23b9a72f8f913ff08f1b2ca1b10e430711106795..96ae9355218da926b7499b5dc8fb3a8eeee0bf83 100644 |
--- a/tools/gn/ninja_writer.cc |
+++ b/tools/gn/ninja_writer.cc |
@@ -5,11 +5,13 @@ |
#include "tools/gn/ninja_writer.h" |
#include "tools/gn/builder.h" |
+#include "tools/gn/dereference_comparator.h" |
#include "tools/gn/loader.h" |
#include "tools/gn/location.h" |
#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 +32,11 @@ bool NinjaWriter::RunAndWriteFiles(const BuildSettings* build_settings, |
std::vector<const Target*> default_targets; |
if (!writer.WriteToolchains(&all_settings, &default_targets, err)) |
return false; |
+ |
+ // Sort the targets so that outputs have a consistent order. |
+ std::sort(default_targets.begin(), default_targets.end(), |
+ DereferenceComparator<Target>()); |
+ |
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(); |
+ ++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(), |