interpreter: Already configured fallback should be used for optional dep
This commit is contained in:
parent
95c3fee47d
commit
f7a07ee91a
|
@ -3585,13 +3585,15 @@ external dependencies (including libraries) must go to "dependencies".''')
|
|||
return self.notfound_dependency()
|
||||
|
||||
has_fallback = 'fallback' in kwargs
|
||||
if not has_fallback and name and required:
|
||||
if not has_fallback and name:
|
||||
# Add an implicit fallback if we have a wrap file or a directory with the same name,
|
||||
# but only if this dependency is required. It is common to first check for a pkg-config,
|
||||
# then fallback to use find_library() and only afterward check again the dependency
|
||||
# with a fallback.
|
||||
# with a fallback. If the fallback has already been configured then we have to use it
|
||||
# even if the dependency is not required.
|
||||
provider = self.environment.wrap_resolver.find_dep_provider(name)
|
||||
if provider:
|
||||
dirname = mesonlib.listify(provider)[0]
|
||||
if provider and (required or dirname in self.subprojects):
|
||||
kwargs['fallback'] = provider
|
||||
has_fallback = True
|
||||
|
||||
|
|
|
@ -40,3 +40,10 @@ assert(d.found(), 'Should implicitly fallback')
|
|||
# sub_implicit_provide2.
|
||||
d = dependency('sub_implicit_provide2')
|
||||
assert(d.found(), 'Should implicitly fallback')
|
||||
|
||||
# sub_implicit.wrap provides glib-2.0 and we already configured that subproject,
|
||||
# so we must not return the system dependency here. Using glib-2.0 here because
|
||||
# some CI runners have it installed.
|
||||
d = dependency('glib-2.0', required : false)
|
||||
assert(d.found())
|
||||
assert(d.type_name() == 'internal')
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[wrap-file]
|
||||
|
||||
[provide]
|
||||
glib-2.0 = glib_dep
|
||||
dependency_names = sub_implicit_provide1
|
||||
sub_implicit_provide2 = sub_implicit_provide2_dep
|
||||
|
|
|
@ -6,3 +6,6 @@ meson.override_dependency('sub_implicit_provide1', dep)
|
|||
|
||||
# This one is not overriden but the wrap file tells the variable name to use.
|
||||
sub_implicit_provide2_dep = dep
|
||||
|
||||
# This one is not overriden but the wrap file tells the variable name to use.
|
||||
glib_dep = dep
|
||||
|
|
Loading…
Reference in New Issue