aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2020-11-18 22:52:57 +0200
committerGitHub <noreply@github.com>2020-11-18 22:52:57 +0200
commit1c582a9de4cd0e5f332ba5b626034f62baf103c6 (patch)
tree08c30e539405d33dfb9b496d6b2cfeff5e4c16ff
parentf1ce78d77f178deb7a458235132d1fc8c44d0afe (diff)
parent0b2865e8b95ef119271011c5854836589e8866ad (diff)
downloadmeson-1c582a9de4cd0e5f332ba5b626034f62baf103c6.zip
meson-1c582a9de4cd0e5f332ba5b626034f62baf103c6.tar.gz
meson-1c582a9de4cd0e5f332ba5b626034f62baf103c6.tar.bz2
Merge pull request #7900 from bonzini/stabilize-hash
Avoid build.ninja changes due to order of hash table iteration
-rw-r--r--mesonbuild/backend/ninjabackend.py4
-rw-r--r--mesonbuild/depfile.py2
-rw-r--r--mesonbuild/interpreterbase.py4
-rw-r--r--mesonbuild/modules/sourceset.py4
-rwxr-xr-xrun_unittests.py2
5 files changed, 8 insertions, 8 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index c3c5705..15218c1 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -359,9 +359,9 @@ class NinjaBuildElement:
rulename = self.rulename
line = 'build {}{}: {} {}'.format(outs, implicit_outs, rulename, ins)
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:
- 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'
# This is the only way I could find to make this work on all
# platforms including Windows command shell. Slash is a dir separator
diff --git a/mesonbuild/depfile.py b/mesonbuild/depfile.py
index 7a896cd..62cbe81 100644
--- a/mesonbuild/depfile.py
+++ b/mesonbuild/depfile.py
@@ -82,4 +82,4 @@ class DepFile:
deps.update(target.deps)
for dep in target.deps:
deps.update(self.get_all_dependencies(dep, visited))
- return deps
+ return sorted(deps)
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py
index d3f8181..e57580b 100644
--- a/mesonbuild/interpreterbase.py
+++ b/mesonbuild/interpreterbase.py
@@ -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):
if len(node.varnames) != 2:
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[1], value)
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 len(posargs) != 0:
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)
diff --git a/mesonbuild/modules/sourceset.py b/mesonbuild/modules/sourceset.py
index e23e12e..e49a548 100644
--- a/mesonbuild/modules/sourceset.py
+++ b/mesonbuild/modules/sourceset.py
@@ -14,7 +14,7 @@
from collections import namedtuple
from .. import mesonlib
-from ..mesonlib import listify
+from ..mesonlib import listify, OrderedSet
from . import ExtensionModule
from ..interpreterbase import (
noPosargs, noKwargs, permittedKwargs,
@@ -111,7 +111,7 @@ class SourceSetHolder(MutableInterpreterObject, ObjectHolder):
def collect(self, enabled_fn, all_sources, into=None):
if not into:
- into = SourceFiles(set(), set())
+ into = SourceFiles(OrderedSet(), OrderedSet())
for entry in self.held_object:
if all(x.found() for x in entry.dependencies) and \
all(enabled_fn(key) for key in entry.keys):
diff --git a/run_unittests.py b/run_unittests.py
index 7f7df36..9815058 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1187,7 +1187,7 @@ class InternalTests(unittest.TestCase):
]:
d = mesonbuild.depfile.DepFile(f)
deps = d.get_all_dependencies(target)
- self.assertEqual(deps, expdeps)
+ self.assertEqual(sorted(deps), sorted(expdeps))
def test_log_once(self):
f = io.StringIO()