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

Unified Diff: pylib/gyp/generator/ninja.py

Issue 1506733002: GYP: Make GYP build deterministic (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: All tested 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: pylib/gyp/generator/ninja.py
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index b13affe0a172392ae115201874d5f44223b38c38..6726dd35e15790ea372475a258882196c644664e 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -15,6 +15,8 @@ import sys
import gyp
import gyp.common
from gyp.common import OrderedSet
+from gyp.common import OrderDeterministically
+
import gyp.msvs_emulation
import gyp.MSVSUtil as MSVSUtil
import gyp.xcode_emulation
@@ -656,6 +658,7 @@ class NinjaWriter(object):
for var in special_locals:
if '${%s}' % var in argument:
needed_variables.add(var)
+ needed_variables = OrderDeterministically(needed_variables)
def cygwin_munge(path):
# pylint: disable=cell-var-from-loop
@@ -687,10 +690,8 @@ class NinjaWriter(object):
outputs = [self.ExpandRuleVariables(o, root, dirname,
source, ext, basename)
for o in rule['outputs']]
-
if int(rule.get('process_outputs_as_sources', False)):
extra_sources += outputs
-
was_mac_bundle_resource = source in mac_bundle_resources
if was_mac_bundle_resource or \
int(rule.get('process_outputs_as_mac_bundle_resources', False)):
@@ -700,7 +701,6 @@ class NinjaWriter(object):
# a performance issue.
if was_mac_bundle_resource:
mac_bundle_resources.remove(source)
-
extra_bindings = []
for var in needed_variables:
if var == 'root':
@@ -729,6 +729,7 @@ class NinjaWriter(object):
# WriteNewNinjaRule uses unique_name for creating an rsp file on win.
extra_bindings.append(('unique_name',
hashlib.md5(outputs[0]).hexdigest()))
+
self.ninja.build(outputs, rule_name, self.GypPathToNinja(source),
implicit=inputs,
order_only=prebuild,
@@ -1252,11 +1253,12 @@ class NinjaWriter(object):
if len(solibs):
- extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs)))
+ extra_bindings.append(('solibs',
+ gyp.common.EncodePOSIXShellList(OrderDeterministically(solibs))))
ninja_file.build(output, command + command_suffix, link_deps,
- implicit=list(implicit_deps),
- order_only=list(order_deps),
+ implicit=OrderDeterministically(implicit_deps),
+ order_only=order_deps,
variables=extra_bindings)
return linked_binary
@@ -2337,9 +2339,9 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
# able to run actions and build libraries by their short name.
master_ninja.newline()
master_ninja.comment('Short names for targets.')
- for short_name in target_short_names:
- master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in
- target_short_names[short_name]])
+ for short_name in OrderDeterministically(target_short_names):
+ master_ninja.build(short_name, 'phony', ([x.FinalOutput() for x in
+ target_short_names[short_name]]))
# Write phony targets for any empty targets that weren't written yet. As
# short names are not necessarily unique only do this for short names that
@@ -2348,12 +2350,12 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
if empty_target_names:
master_ninja.newline()
master_ninja.comment('Empty targets (output for completeness).')
- for name in sorted(empty_target_names):
+ for name in OrderDeterministically(empty_target_names):
master_ninja.build(name, 'phony')
if all_outputs:
master_ninja.newline()
- master_ninja.build('all', 'phony', list(all_outputs))
+ master_ninja.build('all', 'phony', OrderDeterministically(all_outputs))
master_ninja.default(generator_flags.get('default_target', 'all'))
master_ninja_file.close()

Powered by Google App Engine
This is Rietveld 408576698