aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-05-30 02:22:20 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-05-30 03:35:02 +0530
commitc33e7a68a1ca1a528612934359a5b3d08005c0aa (patch)
treef556802a50a63465293d61fe02b13a0277acdbec
parentf2256ba0980d1d5eb22b202dacc15abd9249339a (diff)
downloadmeson-c33e7a68a1ca1a528612934359a5b3d08005c0aa.zip
meson-c33e7a68a1ca1a528612934359a5b3d08005c0aa.tar.gz
meson-c33e7a68a1ca1a528612934359a5b3d08005c0aa.tar.bz2
Also reuse subproject-based fallback dependencies
This allows a project to use the same fallbacks dependency from the same subproject multiple times in the same way that external dependencies can be. Also change the format of the dependency identifier to ensure that fallback checks with different dirname/varname aren't mistakenly reused. We now use a tuple for this because the format is simpler to construct and it gives us the same immutability guarantees as a string which is needed for using it as a dictionary key.
-rw-r--r--mesonbuild/dependencies.py10
-rw-r--r--mesonbuild/interpreter.py4
2 files changed, 12 insertions, 2 deletions
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py
index 7462bd8..271c6b4 100644
--- a/mesonbuild/dependencies.py
+++ b/mesonbuild/dependencies.py
@@ -1148,7 +1148,15 @@ def get_dep_identifier(name, kwargs):
modlist = [modlist]
for module in modlist:
elements.append(module)
- return '/'.join(elements) + '/main' + str(kwargs.get('main', False)) + '/static' + str(kwargs.get('static', False))
+ # We use a tuple because we need a non-mutable structure to use as the key
+ # of a dictionary and a string has potential for name collisions
+ identifier = tuple(elements)
+ identifier += ('main', kwargs.get('main', False))
+ identifier += ('static', kwargs.get('static', False))
+ if 'fallback' in kwargs:
+ f = kwargs.get('fallback')
+ identifier += ('fallback', f[0], f[1])
+ return identifier
def find_external_dependency(name, environment, kwargs):
required = kwargs.get('required', True)
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 5a99e1c..1491767 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1626,7 +1626,9 @@ class Interpreter():
dep = dependencies.find_external_dependency(name, self.environment, kwargs)
except dependencies.DependencyException:
if 'fallback' in kwargs:
- return self.dependency_fallback(kwargs)
+ dep = self.dependency_fallback(kwargs)
+ self.coredata.deps[identifier] = dep.held_object
+ return dep
raise
self.coredata.deps[identifier] = dep
return DependencyHolder(dep)