aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-10-25 14:08:24 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-10-25 14:36:16 +0530
commit706425abd172df6686aab40f110b341c62721361 (patch)
treed5e4b533cef1d4c2961d3592faec7ccdcfd79f3b
parent3c48bd2d88e94db2c9f6e714b7b320889a5dcb38 (diff)
downloadmeson-706425abd172df6686aab40f110b341c62721361.zip
meson-706425abd172df6686aab40f110b341c62721361.tar.gz
meson-706425abd172df6686aab40f110b341c62721361.tar.bz2
Ninja: Use OrderedDict in places where order matters
Specifically, wherever we have sources or outputs, we want to use an OrderedDict so that the build is always deterministic. It was reported by Olexa Bilaniuk that `ar D` creates static libraries with different checksums depending on the order of the object files. See: https://github.com/mesonbuild/meson/pull/951 We don't actually want to preserve the order in which they are listed. We just want the order to be deterministic and predictable.
-rw-r--r--mesonbuild/backend/ninjabackend.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index f826f89..0a02504 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -23,6 +23,7 @@ from .backends import InstallData
from ..build import InvalidArguments
import os, sys, pickle, re
import subprocess, shutil
+from collections import OrderedDict
if mesonlib.is_windows():
quote_char = '"'
@@ -239,7 +240,7 @@ int dummy;
(relative to the build directory) of that type and the value
being the GeneratorList or CustomTarget that generated it.
"""
- srcs = {}
+ srcs = OrderedDict()
for gensrc in target.get_generated_sources():
for s in gensrc.get_outputs():
f = self.get_target_generated_dir(target, gensrc, s)
@@ -247,7 +248,7 @@ int dummy;
return srcs
def get_target_sources(self, target):
- srcs = {}
+ srcs = OrderedDict()
for s in target.get_sources():
# BuildTarget sources are always mesonlib.File files which are
# either in the source root, or generated with configure_file and
@@ -300,10 +301,10 @@ int dummy;
# Pre-existing target C/C++ sources to be built; dict of full path to
# source relative to build root and the original File object.
- target_sources = {}
+ target_sources = OrderedDict()
# GeneratedList and CustomTarget sources to be built; dict of the full
# path to source relative to build root and the generating target/list
- generated_sources = {}
+ generated_sources = OrderedDict()
# Array of sources generated by valac that have to be compiled
vala_generated_sources = []
if 'vala' in target.compilers:
@@ -939,10 +940,10 @@ int dummy;
the keys being the path to the file (relative to the build directory)
and the value being the object that generated or represents the file.
"""
- vala = {}
- vapi = {}
- others = {}
- othersgen = {}
+ vala = OrderedDict()
+ vapi = OrderedDict()
+ others = OrderedDict()
+ othersgen = OrderedDict()
# Split pre-existing sources
for s in t.get_sources():
# BuildTarget sources are always mesonlib.File files which are
@@ -1088,7 +1089,7 @@ int dummy;
args += ['--out-dir', target.subdir]
args += ['--emit', 'dep-info', '--emit', 'link']
orderdeps = [os.path.join(t.subdir, t.get_filename()) for t in target.link_targets]
- linkdirs = {}
+ linkdirs = OrderedDict()
for d in target.link_targets:
linkdirs[d.subdir] = True
for d in linkdirs.keys():