Merge pull request #1548 from ssssam/sam/stable-ordering

Stable ordering of some commandlines generated by 'gnome' module
pull/1625/head
Jussi Pakkanen 8 years ago committed by GitHub
commit b951e60f06
  1. 3
      mesonbuild/backend/backends.py
  2. 5
      mesonbuild/backend/ninjabackend.py
  3. 15
      mesonbuild/build.py
  4. 16
      mesonbuild/mesonlib.py
  5. 10
      mesonbuild/modules/gnome.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:

@ -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):

@ -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)

@ -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

@ -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]

Loading…
Cancel
Save