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

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: Moves sort into ninja_toolchain_writer.cc for consistency 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..d3b65dbbcb90bcf3b36b194fdc6bc33d1315aa56 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,9 @@ bool NinjaToolchainWriter::RunAndWriteFile(
if (file.fail())
return false;
+ // Sort here to ensure the files are deterministically ordered.
M-A Ruel 2015/12/07 00:20:16 You could DCHECK instead that the list is sorted.
Zachary Forman 2015/12/07 03:18:17 This is poor phrasing on my part - they come in un
+ std::sort(targets.begin(), targets.end(), DereferenceComparator<Target>());
+
NinjaToolchainWriter gen(settings, toolchain, targets, file);
gen.Run();
return true;

Powered by Google App Engine
This is Rietveld 408576698