diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-04-13 23:59:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 23:59:48 +0300 |
commit | b951e60f0683c9198d62004a5ef3d4c1cb9ba38f (patch) | |
tree | aaf098f0a1367ce5ebe5e6a239f02e27b5df0269 | |
parent | f0a077e55b1792ea67e1df4d747476bdf5f40eec (diff) | |
parent | 2db11f1383e3d9c59f54f4a742bd44ad85dce226 (diff) | |
download | meson-b951e60f0683c9198d62004a5ef3d4c1cb9ba38f.zip meson-b951e60f0683c9198d62004a5ef3d4c1cb9ba38f.tar.gz meson-b951e60f0683c9198d62004a5ef3d4c1cb9ba38f.tar.bz2 |
Merge pull request #1548 from ssssam/sam/stable-ordering
Stable ordering of some commandlines generated by 'gnome' module
-rw-r--r-- | mesonbuild/backend/backends.py | 3 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 5 | ||||
-rw-r--r-- | mesonbuild/build.py | 15 | ||||
-rw-r--r-- | mesonbuild/mesonlib.py | 16 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 10 |
5 files changed, 39 insertions, 10 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index e49793e..a77047b 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -23,6 +23,7 @@ import subprocess from ..mesonlib import MesonException, get_meson_script from ..mesonlib import get_compiler_for_source, classify_unity_sources from ..compilers import CompilerArgs +from collections import OrderedDict class CleanTrees: ''' @@ -574,7 +575,7 @@ class Backend: return newargs def get_build_by_default_targets(self): - result = {} + result = OrderedDict() # Get all build and custom targets that must be built by default for name, t in self.build.get_targets().items(): if t.build_by_default or t.install or t.build_always: diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index dfb5600..98a2110 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2351,7 +2351,10 @@ rule FORTRAN_DEP_HACK cmds = [] for (k, v) in self.environment.coredata.user_options.items(): cmds.append('-D' + k + '=' + (v.value if isinstance(v.value, str) else str(v.value).lower())) - return cmds + # The order of these arguments must be the same between runs of Meson + # to ensure reproducible output. The order we pass them shouldn't + # affect behaviour in any other way. + return sorted(cmds) # For things like scan-build and other helper tools we might have. def generate_utils(self, outfile): diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 062b70a..6c16cf9 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -83,9 +83,9 @@ class Build: self.project_version = None self.environment = environment self.projects = {} - self.targets = {} - self.compilers = {} - self.cross_compilers = {} + self.targets = OrderedDict() + self.compilers = OrderedDict() + self.cross_compilers = OrderedDict() self.global_args = {} self.projects_args = {} self.global_link_args = {} @@ -345,6 +345,9 @@ class BuildTarget(Target): self.validate_sources() self.validate_cross_install(environment) + def __lt__(self, other): + return self.get_id() < other.get_id() + def __repr__(self): repr_str = "<{0} {1}: {2}>" return repr_str.format(self.__class__.__name__, self.get_id(), self.filename) @@ -1304,6 +1307,9 @@ class CustomTarget(Target): mlog.warning('Unknown keyword arguments in target %s: %s' % (self.name, ', '.join(unknowns))) + def __lt__(self, other): + return self.get_id() < other.get_id() + def __repr__(self): repr_str = "<{0} {1}: {2}>" return repr_str.format(self.__class__.__name__, self.get_id(), self.command) @@ -1470,6 +1476,9 @@ class RunTarget(Target): self.args = args self.dependencies = dependencies + def __lt__(self, other): + return self.get_id() < other.get_id() + def __repr__(self): repr_str = "<{0} {1}: {2}>" return repr_str.format(self.__class__.__name__, self.get_id(), self.command) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 0a8478b..ae2f88c 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -16,6 +16,7 @@ import stat import platform, subprocess, operator, os, shutil, re +import collections from glob import glob @@ -685,3 +686,18 @@ def get_filenames_templates_dict(inputs, outputs): if values['@OUTDIR@'] == '': values['@OUTDIR@'] = '.' return values + +class OrderedSet(collections.OrderedDict): + ''' + A 'set' equivalent that preserves the order in which items are added. + + This is a hack implementation that wraps OrderedDict. It may not be the + most efficient solution and might need fixing to override more methods. + ''' + def __init__(self, iterable=None): + if iterable: + self.update(iterable) + + def update(self, iterable): + for item in iterable: + self[item] = True diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index adb6fa8..6921472 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -21,7 +21,7 @@ import sys import copy import subprocess from . import ModuleReturnValue -from ..mesonlib import MesonException, Popen_safe +from ..mesonlib import MesonException, OrderedSet, Popen_safe from ..dependencies import Dependency, PkgConfigDependency, InternalDependency from .. import mlog from .. import mesonlib @@ -154,7 +154,7 @@ class GnomeModule(ExtensionModule): # Ensure build directories of generated deps are included source_dirs += subdirs - for source_dir in set(source_dirs): + for source_dir in OrderedSet(source_dirs): cmd += ['--sourcedir', source_dir] if 'c_name' in kwargs: @@ -299,9 +299,9 @@ class GnomeModule(ExtensionModule): def _get_dependencies_flags(self, deps, state, depends=None, include_rpath=False, use_gir_args=False): - cflags = set() - ldflags = set() - gi_includes = set() + cflags = OrderedSet() + ldflags = OrderedSet() + gi_includes = OrderedSet() if not isinstance(deps, list): deps = [deps] |