aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/base.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-10-08 12:05:51 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2020-10-08 12:24:07 +0200
commit726b82205492a9e1f2dfd0fba96b237b51eeb428 (patch)
treedf49508fe8547d69b232e90fa2cf6fc17dcc8b2b /mesonbuild/dependencies/base.py
parent1eec5cf41f905c988af4be003a03d29fca7baef4 (diff)
downloadmeson-726b82205492a9e1f2dfd0fba96b237b51eeb428.zip
meson-726b82205492a9e1f2dfd0fba96b237b51eeb428.tar.gz
meson-726b82205492a9e1f2dfd0fba96b237b51eeb428.tar.bz2
dependency: support boolean argument "allow_fallback"
Sometimes, distros want to configure a project so that it does not use any bundled library. In this case, meson.build might want to do something like this, where slirp is a combo option with values auto/system/internal: slirp = dependency('', required: false) if get_option('slirp') != 'internal' slirp = dependency('slirp', required: get_option('slirp') == 'system') endif if not slirp.found() slirp = subproject('libslirp', ...) .variable('...') endif and we cannot use "fallback" because the "system" value should never look for a subproject. This worked until 0.54.x, but in 0.55.x this breaks because of the automatic subproject search. Note that the desired effect here is backwards compared to the policy of doing an automatic search on "required: true"; we only want to do the search if "required" is false! It would be possible to look for the dependency with `required: false` and issue the error manually, but it's ugly and it may produce an error message that looks "different" from Meson's. Instead, with this change it is possible to achieve this effect in an even simpler way: slirp = dependency('slirp', required: get_option('slirp') != 'auto', allow_fallback: get_option('slirp') == 'system' ? false : ['slirp', 'libslirp_dep']) The patch also adds support for "allow_fallback: true", which is simple and enables automatic fallback to a wrap even for non-required dependencies.
Diffstat (limited to 'mesonbuild/dependencies/base.py')
-rw-r--r--mesonbuild/dependencies/base.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 7c64b9c..95202fe 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -2320,9 +2320,11 @@ def get_dep_identifier(name, kwargs) -> T.Tuple:
# 'version' is irrelevant for caching; the caller must check version matches
# 'native' is handled above with `for_machine`
# 'required' is irrelevant for caching; the caller handles it separately
- # 'fallback' subprojects cannot be cached -- they must be initialized
+ # 'fallback' and 'allow_fallback' is not part of the cache because,
+ # once a dependency has been found through a fallback, it should
+ # be used for the rest of the Meson run.
# 'default_options' is only used in fallback case
- if key in ('version', 'native', 'required', 'fallback', 'default_options'):
+ if key in ('version', 'native', 'required', 'fallback', 'allow_fallback', 'default_options'):
continue
# All keyword arguments are strings, ints, or lists (or lists of lists)
if isinstance(value, list):