diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2018-12-27 14:44:24 -0500 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2019-01-16 11:16:46 -0500 |
commit | a92b41fdcd0691c2efc8222be1cb8d3ea1c29aa7 (patch) | |
tree | 8e15ec40983ef01ddba72f8a034469ea47d4f86e | |
parent | 2f72d4db0921ec3ce7c4cd9803c7af9f4ac776cf (diff) | |
download | meson-a92b41fdcd0691c2efc8222be1cb8d3ea1c29aa7.zip meson-a92b41fdcd0691c2efc8222be1cb8d3ea1c29aa7.tar.gz meson-a92b41fdcd0691c2efc8222be1cb8d3ea1c29aa7.tar.bz2 |
dependencies: Remove version from cache key
We cannot have 2 different versions with all other kwargs being
identical. This simplifies a lot that code.
-rw-r--r-- | mesonbuild/dependencies/base.py | 11 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 38 |
2 files changed, 21 insertions, 28 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 35237d0..e9f778b 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -1984,17 +1984,14 @@ class ExtraFrameworkDependency(ExternalDependency): def get_dep_identifier(name, kwargs, want_cross): - # Need immutable objects since the identifier will be used as a dict key - version_reqs = listify(kwargs.get('version', [])) - if isinstance(version_reqs, list): - version_reqs = frozenset(version_reqs) - identifier = (name, version_reqs, want_cross) + identifier = (name, want_cross) for key, value in kwargs.items(): - # 'version' is embedded above as the second element for easy access + # 'version' is irrelevant for caching; the caller must check version matches # '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',): + # 'default_options' is only used in fallback case + if key in ('version', 'native', 'required', 'fallback', 'default_options'): continue # All keyword arguments are strings, ints, or lists (or lists of lists) if isinstance(value, list): diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 125d2cf..1963d3c 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2851,28 +2851,24 @@ external dependencies (including libraries) must go to "dependencies".''') want_cross = not kwargs['native'] else: want_cross = is_cross + identifier = dependencies.get_dep_identifier(name, kwargs, want_cross) - cached_dep = None - # Check if we've already searched for and found this dep - if identifier in self.coredata.deps: - cached_dep = self.coredata.deps[identifier] - mlog.log('Dependency', mlog.bold(name), - 'found:', mlog.green('YES'), '(cached)') - else: - # Check if exactly the same dep with different version requirements - # was found already. - 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 - 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. - cached_dep = trial_dep - break - return identifier, cached_dep + cached_dep = self.coredata.deps.get(identifier) + if cached_dep: + if not cached_dep.found(): + mlog.log('Dependency', mlog.bold(name), + 'found:', mlog.red('NO'), '(cached)') + return identifier, cached_dep + + # Verify the cached dep version match + wanted = kwargs.get('version', []) + found = cached_dep.get_version() + if not wanted or mesonlib.version_compare_many(found, wanted)[0]: + mlog.log('Dependency', mlog.bold(name), + 'found:', mlog.green('YES'), '(cached)') + return identifier, cached_dep + + return identifier, None @staticmethod def check_subproject_version(wanted, found): |