aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-05-30 03:30:53 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-05-30 03:40:30 +0530
commit8c34ea645dfcc2e5043be93fa0f692c24a153a56 (patch)
tree4095d5d828020314a86ab287d809b83e643daa94
parent0096c51035aeeb53e02bca288de0797a790c4d48 (diff)
downloadmeson-8c34ea645dfcc2e5043be93fa0f692c24a153a56.zip
meson-8c34ea645dfcc2e5043be93fa0f692c24a153a56.tar.gz
meson-8c34ea645dfcc2e5043be93fa0f692c24a153a56.tar.bz2
interpreter: Compare the version of a cached dependency() before using it
Without this, checks with incompatible versions but the same library would return true. Example: dependency('zlib', version : '>=1.2') dependency('zlib', version : '<1.0') # this will return the same dep again! Example: https://github.com/mesonbuild/meson/issues/568
-rw-r--r--mesonbuild/interpreter.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index a45c767..f0d22c5 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1617,11 +1617,21 @@ class Interpreter():
self.validate_arguments(args, 1, [str])
name = args[0]
identifier = dependencies.get_dep_identifier(name, kwargs)
+ # Check if we've already searched for and found this dep
+ cached_dep = None
if identifier in self.coredata.deps:
- dep = self.coredata.deps[identifier]
+ cached_dep = self.coredata.deps[identifier]
+ if 'version' in kwargs:
+ wanted = kwargs['version']
+ found = cached_dep.get_version()
+ if not found or not mesonlib.version_compare(found, wanted):
+ # Cached dep has the wrong version. Check if an external
+ # dependency or a fallback dependency provides it.
+ cached_dep = None
+ if cached_dep:
+ dep = cached_dep
else:
- dep = dependencies.Dependency() # Returns always false for dep.found()
- if not dep.found():
+ # We need to actually search for this dep
try:
dep = dependencies.find_external_dependency(name, self.environment, kwargs)
except dependencies.DependencyException: