diff options
author | Rafael Ăvila de EspĂndola <rafael@espindo.la> | 2018-07-22 22:24:42 -0700 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-07-22 22:24:42 -0700 |
commit | 1a27714f97b8f6d716e376e9fcf8e9f79f029c86 (patch) | |
tree | 72e8d1e702d6086a68e6011b460043f5a937c9cb | |
parent | 6fafbad6d5ba591075a72e4726af647cece7020d (diff) | |
download | meson-1a27714f97b8f6d716e376e9fcf8e9f79f029c86.zip meson-1a27714f97b8f6d716e376e9fcf8e9f79f029c86.tar.gz meson-1a27714f97b8f6d716e376e9fcf8e9f79f029c86.tar.bz2 |
Make the dependency order deterministic. (#3927)
We were using sets to store the dependencies. Just switch to
OrderedSet.
Fixes #3922.
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 4 | ||||
-rwxr-xr-x | run_unittests.py | 13 | ||||
-rw-r--r-- | test cases/common/206 dep order/lib1.c | 0 | ||||
-rw-r--r-- | test cases/common/206 dep order/lib2.c | 0 | ||||
-rw-r--r-- | test cases/common/206 dep order/meson.build | 8 | ||||
-rw-r--r-- | test cases/common/206 dep order/myexe.c | 3 |
6 files changed, 26 insertions, 2 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 035f835..c248ae8 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -73,8 +73,8 @@ class NinjaBuildElement: self.infilenames = [infilenames] else: self.infilenames = infilenames - self.deps = set() - self.orderdeps = set() + self.deps = OrderedSet() + self.orderdeps = OrderedSet() self.elems = [] self.all_outputs = all_outputs diff --git a/run_unittests.py b/run_unittests.py index dd109aa..912c843 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3587,6 +3587,19 @@ endian = 'little' self.build() self.run_tests() + def test_deterministic_dep_order(self): + ''' + Test that the dependencies are always listed in a deterministic order. + ''' + testdir = os.path.join(self.common_test_dir, '206 dep order') + self.init(testdir) + with open(os.path.join(self.builddir, 'build.ninja')) as bfile: + for line in bfile: + if 'build myexe:' in line or 'build myexe.exe:' in line: + self.assertIn('liblib1.a liblib2.a', line) + return + raise RuntimeError('Could not find the build rule') + @skipIfNoPkgconfig def test_usage_external_library(self): ''' diff --git a/test cases/common/206 dep order/lib1.c b/test cases/common/206 dep order/lib1.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/common/206 dep order/lib1.c diff --git a/test cases/common/206 dep order/lib2.c b/test cases/common/206 dep order/lib2.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/common/206 dep order/lib2.c diff --git a/test cases/common/206 dep order/meson.build b/test cases/common/206 dep order/meson.build new file mode 100644 index 0000000..17cf9df --- /dev/null +++ b/test cases/common/206 dep order/meson.build @@ -0,0 +1,8 @@ +project('myexe', 'c') + +lib1 = static_library('lib1', 'lib1.c') +lib2 = static_library('lib2', 'lib2.c') + +executable('myexe', + 'myexe.c', + link_with: [lib1, lib2]) diff --git a/test cases/common/206 dep order/myexe.c b/test cases/common/206 dep order/myexe.c new file mode 100644 index 0000000..8f4c045 --- /dev/null +++ b/test cases/common/206 dep order/myexe.c @@ -0,0 +1,3 @@ +int main(int ac, char** av) { + return 0; +} |