dependency: Empty fallback is the same as allow_fallback: false

This commit is contained in:
Xavier Claessens 2021-06-17 14:41:55 -04:00 committed by Xavier Claessens
parent d729ea3f69
commit 5f3b73beb5
5 changed files with 22 additions and 0 deletions

View File

@ -515,6 +515,8 @@ This function supports the following keyword arguments:
in this case the subproject must use
`meson.override_dependency('dependency_name', subproj_dep)`
to specify the dependency object used in the superproject.
If the value is an empty list, it has the same effect as
`allow_fallback: false`.
- `language` *(since 0.42.0)*: defines what language-specific
dependency to find if it's available for multiple languages.
- `method`: defines the way the dependency is detected, the default is

View File

@ -47,6 +47,10 @@ class DependencyFallbacksHolder(InterpreterObject):
location=self.interpreter.current_node)
return
fbinfo = stringlistify(fbinfo)
if len(fbinfo) == 0:
# dependency('foo', fallback: []) is the same as dependency('foo', allow_fallback: false)
self.allow_fallback = False
return
if len(fbinfo) == 1:
FeatureNew.single_use('Fallback without variable name', '0.53.0', self.subproject)
subp_name, varname = fbinfo[0], None

View File

@ -0,0 +1,6 @@
project('empty fallback')
# There is a subproject named 'foo' that overrides that dependency,
# but `fallback: []` should not allow to use it. Same behaviour than with
# `allow_fallback: false`
dependency('foo', fallback: [])

View File

@ -0,0 +1,3 @@
project('foo')
meson.override_dependency('foo', declare_dependency())

View File

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/115 empty fallback/meson.build:6:0: ERROR: Dependency \"foo\" not found, tried pkgconfig and cmake"
}
]
}