diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-06-23 21:34:54 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2020-07-01 09:51:57 -0400 |
commit | f7a07ee91a77f68e27b1cf60f5ffcd3296f15b7b (patch) | |
tree | bef10623f40b6e48abcce668c712f70fbcca2fb8 | |
parent | 95c3fee47d75ef493865b3ffbcea7989ef246287 (diff) | |
download | meson-f7a07ee91a77f68e27b1cf60f5ffcd3296f15b7b.zip meson-f7a07ee91a77f68e27b1cf60f5ffcd3296f15b7b.tar.gz meson-f7a07ee91a77f68e27b1cf60f5ffcd3296f15b7b.tar.bz2 |
interpreter: Already configured fallback should be used for optional dep
4 files changed, 16 insertions, 3 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 3e64a67..7896f51 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -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 diff --git a/test cases/common/102 subproject subdir/meson.build b/test cases/common/102 subproject subdir/meson.build index 6faff75..93093bf 100644 --- a/test cases/common/102 subproject subdir/meson.build +++ b/test cases/common/102 subproject subdir/meson.build @@ -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') diff --git a/test cases/common/102 subproject subdir/subprojects/sub_implicit.wrap b/test cases/common/102 subproject subdir/subprojects/sub_implicit.wrap index e668a8d..6f2dab6 100644 --- a/test cases/common/102 subproject subdir/subprojects/sub_implicit.wrap +++ b/test cases/common/102 subproject subdir/subprojects/sub_implicit.wrap @@ -1,5 +1,6 @@ [wrap-file] [provide] +glib-2.0 = glib_dep dependency_names = sub_implicit_provide1 sub_implicit_provide2 = sub_implicit_provide2_dep diff --git a/test cases/common/102 subproject subdir/subprojects/sub_implicit/meson.build b/test cases/common/102 subproject subdir/subprojects/sub_implicit/meson.build index 64374d3..24609ae 100644 --- a/test cases/common/102 subproject subdir/subprojects/sub_implicit/meson.build +++ b/test cases/common/102 subproject subdir/subprojects/sub_implicit/meson.build @@ -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 |