aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2016-10-27 21:16:16 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2016-11-02 13:49:57 -0700
commitaeaccdc418e9e12bf64b5b3bd21751e0e71c7c2b (patch)
tree28b013ce74f4259777f8990fcd748e3d5a8d86f5
parentf1c909c41a1e495c08784aefdaa7779c1bb440d3 (diff)
downloadmeson-aeaccdc418e9e12bf64b5b3bd21751e0e71c7c2b.zip
meson-aeaccdc418e9e12bf64b5b3bd21751e0e71c7c2b.tar.gz
meson-aeaccdc418e9e12bf64b5b3bd21751e0e71c7c2b.tar.bz2
Fix dependency() ignoring required attribute when checked second or third time
If first checking for a dependency as not-required, and then later checking for the same dependency again as required, we would not error out saying the dependency is missing, but just silently re-use the cached dependency object from the first check and then likely fail at build time if the dependency is not actually there. With test case. Fixes #964.
-rw-r--r--mesonbuild/interpreter.py7
-rw-r--r--test cases/failing/34 dependency not-required then required/meson.build4
2 files changed, 11 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 5203528..50de9e1 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1860,6 +1860,13 @@ requirements use the version keyword argument instead.''')
# Cached dep has the wrong version. Check if an external
# dependency or a fallback dependency provides it.
cached_dep = None
+
+ # Don't re-use cached dep if it wasn't required but this one is,
+ # so we properly go into fallback/error code paths
+ if 'required' in kwargs and cached_dep is not None:
+ if not cached_dep.required and kwargs.get('required', True):
+ cached_dep = None
+
if cached_dep:
dep = cached_dep
else:
diff --git a/test cases/failing/34 dependency not-required then required/meson.build b/test cases/failing/34 dependency not-required then required/meson.build
new file mode 100644
index 0000000..f33c41c
--- /dev/null
+++ b/test cases/failing/34 dependency not-required then required/meson.build
@@ -0,0 +1,4 @@
+project('dep-test', 'c', version : '1.0')
+
+foo_dep = dependency('foo-bar-xyz-12.3', required : false)
+bar_dep = dependency('foo-bar-xyz-12.3', required : true)