Chromium Code Reviews| Index: tools/gn/ninja_writer.cc |
| diff --git a/tools/gn/ninja_writer.cc b/tools/gn/ninja_writer.cc |
| index 23b9a72f8f913ff08f1b2ca1b10e430711106795..f2c6d98532756d25c97414e5f0704b625df77109 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,11 @@ bool NinjaWriter::RunAndWriteFiles(const BuildSettings* build_settings, |
| std::vector<const Target*> default_targets; |
| if (!writer.WriteToolchains(&all_settings, &default_targets, err)) |
|
mithro-old
2015/12/03 05:20:31
Doesn't sorting in NinjaWriter::WriteToolchains me
Zachary Forman
2015/12/03 07:27:02
Other way around - more than just WriteToolchains
|
| return false; |
| + |
| + // Sort the targets so that outputs have a consistent order. |
|
mithro-old
2015/12/03 05:20:31
Can we get a test for this?
Zachary Forman
2015/12/03 07:27:02
I don't think so. It percolates through a stack of
|
| + std::sort(default_targets.begin(), default_targets.end(), |
| + [](const Target* a, const Target* b) { return *a < *b; }); |
|
mithro-old
2015/12/03 05:20:31
Can you use your comparator here instead of a lamb
Zachary Forman
2015/12/03 07:27:02
Yeah, might as well. It'll be a little nicer.
|
| + |
| return writer.WriteRootBuildfiles(all_settings, default_targets, err); |
| } |
| @@ -70,13 +76,16 @@ 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); |
| + // Sort the toolchain's targets to ensure output is consistently ordered. |
| + std::sort(i->second.begin(), i->second.end(), |
|
mithro-old
2015/12/03 05:20:31
Same as above...
Zachary Forman
2015/12/03 07:27:02
Acknowledged
|
| + [](const Target* a, const Target* b) { return *a < *b; }); |
| if (!NinjaToolchainWriter::RunAndWriteFile(settings, toolchain, |
| i->second)) { |
| Err(Location(), |