From f5b7cfdbf0888fb99956cf2dc661c519aa08a9a4 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sat, 1 Apr 2017 20:04:53 +0100 Subject: Ensure rules in the generated build.ninja file are in a stable order Previously, two functionally identical builds could produce different build.ninja files. The ordering of the rules themselves doesn't affect behaviour, but unnecessary changes in commandline arguments can cause spurious rebuilds and if the ordering of the overall file is stable than it's easy to use `diff` to compare different build.ninja files and spot the differences in ordering that are triggering the unnecessary rebuilds. --- mesonbuild/backend/backends.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 99be172..e37b0df 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -22,6 +22,7 @@ import json import subprocess from ..mesonlib import MesonException, get_compiler_for_source, classify_unity_sources from ..compilers import CompilerArgs +from collections import OrderedDict class CleanTrees: ''' @@ -542,7 +543,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: -- cgit v1.1 From 2db11f1383e3d9c59f54f4a742bd44ad85dce226 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Mon, 3 Apr 2017 17:03:56 +0100 Subject: Sort user commandline options when generating 'scan-build' target We receive these options from the 'argparse' module in a random order. To ensure the build.ninja file doesn't include random variations we should sort them before writing them back out. --- mesonbuild/backend/ninjabackend.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index f29a7be..63db854 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2276,7 +2276,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): -- cgit v1.1