From c7d71c79434d98c280121ac1a20faca8fd512e40 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sun, 7 May 2017 02:01:41 +0530 Subject: dependencies: Fix caching of native/cross dependencies All our cached_dep magic was totally useless since we ended up using the same identifier for native and cross deps. Just nuke all this cached_dep code since it is very error-prone and improve the identifier generation instead. For instance, this is broken *right now* with the `type_name` kwarg. Add a bunch of tests to ensure that all this actually works... Closes https://github.com/mesonbuild/meson/issues/1736 --- mesonbuild/dependencies.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'mesonbuild/dependencies.py') diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index 37e2cbd..2267492 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -1742,21 +1742,17 @@ class LLVMDependency(Dependency): return True -def get_dep_identifier(name, kwargs): - elements = [name] - modlist = kwargs.get('modules', []) - if isinstance(modlist, str): - modlist = [modlist] - for module in modlist: - elements.append(module) - # 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]) +def get_dep_identifier(name, kwargs, want_cross): + # Need immutable objects since the identifier will be used as a dict key + identifier = (name, want_cross) + for key, value in kwargs.items(): + # Ignore versions, they will be handled by the caller + if key == 'version': + continue + # All keyword arguments are strings, ints, or lists (or lists of lists) + if isinstance(value, list): + value = frozenset(mesonlib.flatten(value)) + identifier += (key, value) return identifier def find_external_dependency(name, environment, kwargs): -- cgit v1.1