Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid build.ninja changes due to order of hash table iteration #7900

Merged
merged 3 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ def write(self, outfile):
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
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/depfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ def get_all_dependencies(self, target, visited=None):
deps.update(target.deps)
for dep in target.deps:
deps.update(self.get_all_dependencies(dep, visited))
return deps
return sorted(deps)
4 changes: 2 additions & 2 deletions mesonbuild/interpreterbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def evaluate_foreach(self, node: mparser.ForeachClauseNode) -> None:
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:
Expand Down Expand Up @@ -1166,7 +1166,7 @@ def dict_method_call(self, obj: T.Dict[str, TYPE_var], method_name: str, posargs
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)

Expand Down
4 changes: 2 additions & 2 deletions mesonbuild/modules/sourceset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -111,7 +111,7 @@ def add_all_method(self, args, kwargs):

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):
Expand Down
2 changes: 1 addition & 1 deletion run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ def test_depfile(self):
]:
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()
Expand Down