Merge pull request #7900 from bonzini/stabilize-hash

Avoid build.ninja changes due to order of hash table iteration
pull/8005/head
Jussi Pakkanen 4 years ago committed by GitHub
commit 1c582a9de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      mesonbuild/backend/ninjabackend.py
  2. 2
      mesonbuild/depfile.py
  3. 4
      mesonbuild/interpreterbase.py
  4. 4
      mesonbuild/modules/sourceset.py
  5. 2
      run_unittests.py

@ -359,9 +359,9 @@ class NinjaBuildElement:
rulename = self.rulename rulename = self.rulename
line = 'build {}{}: {} {}'.format(outs, implicit_outs, rulename, ins) line = 'build {}{}: {} {}'.format(outs, implicit_outs, rulename, ins)
if len(self.deps) > 0: if len(self.deps) > 0:
line += ' | ' + ' '.join([ninja_quote(x, True) for x in self.deps]) line += ' | ' + ' '.join([ninja_quote(x, True) for x in sorted(self.deps)])
if len(self.orderdeps) > 0: if len(self.orderdeps) > 0:
line += ' || ' + ' '.join([ninja_quote(x, True) for x in self.orderdeps]) line += ' || ' + ' '.join([ninja_quote(x, True) for x in sorted(self.orderdeps)])
line += '\n' line += '\n'
# This is the only way I could find to make this work on all # This is the only way I could find to make this work on all
# platforms including Windows command shell. Slash is a dir separator # platforms including Windows command shell. Slash is a dir separator

@ -82,4 +82,4 @@ class DepFile:
deps.update(target.deps) deps.update(target.deps)
for dep in target.deps: for dep in target.deps:
deps.update(self.get_all_dependencies(dep, visited)) deps.update(self.get_all_dependencies(dep, visited))
return deps return sorted(deps)

@ -823,7 +823,7 @@ The result of this is undefined and will become a hard error in a future Meson r
elif isinstance(items, dict): elif isinstance(items, dict):
if len(node.varnames) != 2: if len(node.varnames) != 2:
raise InvalidArguments('Foreach on dict unpacks key and value') raise InvalidArguments('Foreach on dict unpacks key and value')
for key, value in items.items(): for key, value in sorted(items.items()):
self.set_variable(node.varnames[0], key) self.set_variable(node.varnames[0], key)
self.set_variable(node.varnames[1], value) self.set_variable(node.varnames[1], value)
try: try:
@ -1166,7 +1166,7 @@ The result of this is undefined and will become a hard error in a future Meson r
if method_name == 'keys': if method_name == 'keys':
if len(posargs) != 0: if len(posargs) != 0:
raise InterpreterException('keys() takes no arguments.') raise InterpreterException('keys() takes no arguments.')
return list(obj.keys()) return sorted(obj.keys())
raise InterpreterException('Dictionaries do not have a method called "%s".' % method_name) raise InterpreterException('Dictionaries do not have a method called "%s".' % method_name)

@ -14,7 +14,7 @@
from collections import namedtuple from collections import namedtuple
from .. import mesonlib from .. import mesonlib
from ..mesonlib import listify from ..mesonlib import listify, OrderedSet
from . import ExtensionModule from . import ExtensionModule
from ..interpreterbase import ( from ..interpreterbase import (
noPosargs, noKwargs, permittedKwargs, noPosargs, noKwargs, permittedKwargs,
@ -111,7 +111,7 @@ class SourceSetHolder(MutableInterpreterObject, ObjectHolder):
def collect(self, enabled_fn, all_sources, into=None): def collect(self, enabled_fn, all_sources, into=None):
if not into: if not into:
into = SourceFiles(set(), set()) into = SourceFiles(OrderedSet(), OrderedSet())
for entry in self.held_object: for entry in self.held_object:
if all(x.found() for x in entry.dependencies) and \ if all(x.found() for x in entry.dependencies) and \
all(enabled_fn(key) for key in entry.keys): all(enabled_fn(key) for key in entry.keys):

@ -1187,7 +1187,7 @@ class InternalTests(unittest.TestCase):
]: ]:
d = mesonbuild.depfile.DepFile(f) d = mesonbuild.depfile.DepFile(f)
deps = d.get_all_dependencies(target) deps = d.get_all_dependencies(target)
self.assertEqual(deps, expdeps) self.assertEqual(sorted(deps), sorted(expdeps))
def test_log_once(self): def test_log_once(self):
f = io.StringIO() f = io.StringIO()

Loading…
Cancel
Save