aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-10-26 06:13:38 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2020-11-15 14:21:31 +0100
commitfc9b0cbb7fe718cbbd63e3b51839b90b3e558037 (patch)
tree827db8968b02fe10d0ad6adfbddd927f6c8b5afc
parent59cacbbfc17dffe4aede1dfaa93bd5e1a3e994b2 (diff)
downloadmeson-fc9b0cbb7fe718cbbd63e3b51839b90b3e558037.zip
meson-fc9b0cbb7fe718cbbd63e3b51839b90b3e558037.tar.gz
meson-fc9b0cbb7fe718cbbd63e3b51839b90b3e558037.tar.bz2
stabilize sets that are converted to lists
The order of elements in sets cannot be relied upon, because the hash values are randomized by Python. Whenever sets are converted to lists we need to keep their order stable, or random changes in the command line cause ninja to rebuild a lot of files unnecessarily. To stabilize them, use either sort or OrderedSet. Sorting is not always applicable, but it can be faster because it's done in C and it can produce slightly nicer output.
-rw-r--r--mesonbuild/depfile.py2
-rw-r--r--mesonbuild/modules/sourceset.py4
-rwxr-xr-xrun_unittests.py2
3 files changed, 4 insertions, 4 deletions
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/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()