Permalink
Browse files

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

Stable ordering of some commandlines generated by 'gnome' module
  • Loading branch information...
jpakkane committed Apr 13, 2017
2 parents f0a077e + 2db11f1 commit b951e60f0683c9198d62004a5ef3d4c1cb9ba38f
@@ -23,6 +23,7 @@
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 @@ def replace_outputs(self, args, private_dir, output_list):
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 @@ def get_user_option_args(self):
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):
View
@@ -83,9 +83,9 @@ def __init__(self, environment):
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 @@ def __init__(self, name, subdir, subproject, is_cross, sources, objects, environ
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 @@ def __init__(self, name, subdir, kwargs, absolute_paths=False):
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 @@ def __init__(self, name, command, args, dependencies, subdir):
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)
View
@@ -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 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 @@ def compile_resources(self, state, args, kwargs):
# 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 @@ def _get_link_args(self, state, lib, depends=None, include_rpath=False,
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]

0 comments on commit b951e60

Please sign in to comment.