aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2019-11-25 14:44:40 -0500
committerXavier Claessens <xavier.claessens@collabora.com>2020-03-06 15:26:02 -0500
commit141401c11d8900775a15a91ee6ca4dbeac2dfe87 (patch)
treea4b7bbccc58668aaf029535dc4561ce3e029ca2d
parent943e9368f7198b6c2b069ad024ee798037f3c35e (diff)
downloadmeson-141401c11d8900775a15a91ee6ca4dbeac2dfe87.zip
meson-141401c11d8900775a15a91ee6ca4dbeac2dfe87.tar.gz
meson-141401c11d8900775a15a91ee6ca4dbeac2dfe87.tar.bz2
Allow override_dependency() with a not-found dep
-rw-r--r--mesonbuild/interpreter.py7
-rw-r--r--test cases/common/102 subproject subdir/meson.build4
-rw-r--r--test cases/common/102 subproject subdir/subprojects/sub_novar/meson.build1
3 files changed, 12 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 4201141..b3789c3 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -3244,6 +3244,13 @@ external dependencies (including libraries) must go to "dependencies".''')
cached_dep = self.build.dependency_overrides[for_machine].get(identifier)
if cached_dep:
+ # We don't implicitly override not-found dependencies, but user could
+ # have explicitly called meson.override_dependency() with a not-found
+ # dep.
+ if not cached_dep.found():
+ mlog.log('Dependency', mlog.bold(name),
+ 'found:', mlog.red('NO'), mlog.blue('(cached)'))
+ return identifier, cached_dep
found_vers = cached_dep.get_version()
if not self.check_version(wanted_vers, found_vers):
mlog.log('Dependency', mlog.bold(name),
diff --git a/test cases/common/102 subproject subdir/meson.build b/test cases/common/102 subproject subdir/meson.build
index 3004f57..8299a37 100644
--- a/test cases/common/102 subproject subdir/meson.build
+++ b/test cases/common/102 subproject subdir/meson.build
@@ -21,3 +21,7 @@ assert(d.found(), 'Should fallback even if a previous call returned not-found')
# Verify we can get a fallback dependency without specifying the variable name,
# because the subproject overridden 'sub-novar'.
dependency('sub-novar', fallback : 'sub_novar')
+
+# Verify a subproject can force a dependency to be not-found
+d = dependency('sub-notfound', fallback : 'sub_novar', required : false)
+assert(not d.found(), 'Dependency should be not-found')
diff --git a/test cases/common/102 subproject subdir/subprojects/sub_novar/meson.build b/test cases/common/102 subproject subdir/subprojects/sub_novar/meson.build
index 0126b5f..6450a10 100644
--- a/test cases/common/102 subproject subdir/subprojects/sub_novar/meson.build
+++ b/test cases/common/102 subproject subdir/subprojects/sub_novar/meson.build
@@ -1,3 +1,4 @@
project('sub-novar', 'c', version : '1.0')
meson.override_dependency('sub-novar', declare_dependency())
+meson.override_dependency('sub-notfound', dependency('', required : false))