diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-05-07 11:15:47 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-05-09 14:24:48 +0530 |
commit | 8cf29bd288cb67008a42a5c9503042f975c04a43 (patch) | |
tree | 8551ef78da98a87be4f83298be718942111136bc /mesonbuild/dependencies.py | |
parent | 1570a90822941b3f0e6cc8efa50002eb528bee43 (diff) | |
download | meson-8cf29bd288cb67008a42a5c9503042f975c04a43.zip meson-8cf29bd288cb67008a42a5c9503042f975c04a43.tar.gz meson-8cf29bd288cb67008a42a5c9503042f975c04a43.tar.bz2 |
Completely overhaul caching of external dependencies
The old caching was a mess of spaghetti code layered over pasta code.
The new code is well-commented, is clear about what it's trying to do,
and uses a blacklist of keyword arguments instead of a whitelist while
generating identifiers for dep caching which makes it much more robust
for future changes.
The only side-effect of forgetting about a new keyword argument would
be that the dependency would not be cached unless the values of that
keyword arguments were the same in the cached and new dependency.
There are also more tests which identify scenarios that were broken
earlier.
Diffstat (limited to 'mesonbuild/dependencies.py')
-rw-r--r-- | mesonbuild/dependencies.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index a06c069..ae04544 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -27,9 +27,10 @@ import subprocess import sysconfig from enum import Enum from collections import OrderedDict -from . mesonlib import MesonException, version_compare, version_compare_many, Popen_safe from . import mlog from . import mesonlib +from .mesonlib import Popen_safe, flatten +from .mesonlib import MesonException, version_compare, version_compare_many from .environment import detect_cpu_family, for_windows class DependencyException(MesonException): @@ -103,6 +104,7 @@ class InternalDependency(Dependency): def __init__(self, version, incdirs, compile_args, link_args, libraries, sources, ext_deps): super().__init__('internal', {}) self.version = version + self.is_found = True self.include_directories = incdirs self.compile_args = compile_args self.link_args = link_args @@ -1744,14 +1746,20 @@ class LLVMDependency(Dependency): 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) + version_reqs = flatten(kwargs.get('version', [])) + if isinstance(version_reqs, list): + version_reqs = frozenset(version_reqs) + identifier = (name, version_reqs, want_cross) for key, value in kwargs.items(): - # Ignore versions, they will be handled by the caller - if key == 'version': + # 'version' is embedded above as the second element for easy access + # 'native' is handled above with `want_cross` + # 'required' is irrelevant for caching; the caller handles it separately + # 'fallback' subprojects cannot be cached -- they must be initialized + if key in ('version', 'native', 'required', 'fallback',): continue # All keyword arguments are strings, ints, or lists (or lists of lists) if isinstance(value, list): - value = frozenset(mesonlib.flatten(value)) + value = frozenset(flatten(value)) identifier += (key, value) return identifier |