aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/interpreter.py23
-rw-r--r--test cases/linuxlike/5 dependency versions/meson.build15
2 files changed, 25 insertions, 13 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index c1926d0..0db097e 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1882,25 +1882,24 @@ class Interpreter(InterpreterBase):
# was found already.
# We only return early if we find a usable cached dependency since
# there might be multiple cached dependencies like this.
- w = identifier[1]
+ wanted = identifier[1]
for trial, trial_dep in self.coredata.deps.items():
# trial[1], identifier[1] are the version requirements
if trial[0] != identifier[0] or trial[2:] != identifier[2:]:
continue
- # The version requirements are the only thing that's different.
if trial_dep.found():
- # Cached dependency was found. We're close.
- f = trial_dep.get_version()
- if not w or mesonlib.version_compare_many(f, w)[0]:
- # We either don't care about the version, or the
- # cached dep version matches our requirements! Yay!
+ found = trial_dep.get_version()
+ if not wanted or mesonlib.version_compare_many(found, wanted)[0]:
+ # We either don't care about the version, or our
+ # version requirements matched the trial dep's version,
+ # and the trial dep was a found dep!
return identifier, trial_dep
- elif 'fallback' not in kwargs:
- # this cached dependency matched everything but was
- # not-found. Tentatively set this as the dep to use.
- # If no other cached dep matches, we will use this as the
- # not-found dep.
+ elif not trial[1]:
+ # If the not-found cached dep did not have any version
+ # requirements, this probably means the external dependency
+ # cannot be found.
cached_dep = trial_dep
+ break
# There's a subproject fallback specified for this not-found dependency
# which might provide it, so we must check it.
if cached_dep and not cached_dep.found() and 'fallback' in kwargs:
diff --git a/test cases/linuxlike/5 dependency versions/meson.build b/test cases/linuxlike/5 dependency versions/meson.build
index dabbe98..5c2c262 100644
--- a/test cases/linuxlike/5 dependency versions/meson.build
+++ b/test cases/linuxlike/5 dependency versions/meson.build
@@ -62,11 +62,24 @@ assert(somefail_dep.found() == false, 'somefail_dep found via wrong fallback')
fallbackzlib_dep = dependency('zlib',
fallback : ['somelib', 'fakezlib_dep'])
assert(fallbackzlib_dep.type_name() == 'pkgconfig', 'fallbackzlib_dep should be of type "pkgconfig", not ' + fallbackzlib_dep.type_name())
-# Check that the above dependency was not found because it wasn't checked, not because the fallback didn't work
+# Check that the above dependency was pkgconfig because the fallback wasn't
+# checked, not because the fallback didn't work
fakezlib_dep = dependency('fakezlib',
fallback : ['somelib', 'fakezlib_dep'])
assert(fakezlib_dep.type_name() == 'internal', 'fakezlib_dep should be of type "internal", not ' + fakezlib_dep.type_name())
+# Check that you can find a dependency by not specifying a version after not
+# finding it by specifying a version. We add `static: true` here so that the
+# previously cached zlib dependencies don't get checked.
+dependency('zlib', static : true, version : '>=8000', required : false)
+dependency('zlib', static : true)
+
+# Check that you can find a dependency by specifying a correct version after
+# not finding it by specifying a wrong one. We add `method: pkg-config` here so that
+# the previously cached zlib dependencies don't get checked.
+bzip2 = dependency('zlib', method : 'pkg-config', version : '>=9000', required : false)
+bzip2 = dependency('zlib', method : 'pkg-config', version : '>=1.0')
+
if meson.is_cross_build()
# Test caching of native and cross dependencies
# https://github.com/mesonbuild/meson/issues/1736