diff --git a/mesonbuild/dependencies/detect.py b/mesonbuild/dependencies/detect.py index 3784cc0d2840..d84af827faf7 100644 --- a/mesonbuild/dependencies/detect.py +++ b/mesonbuild/dependencies/detect.py @@ -41,24 +41,26 @@ def __contains__(self, key: object) -> bool: def get_dep_identifier(name: str, kwargs: T.Dict[str, T.Any]) -> 'TV_DepID': identifier: 'TV_DepID' = (('name', name), ) from ..interpreter.type_checking import DEPENDENCY_KWS - nkwargs = {k.name: k.default for k in DEPENDENCY_KWS} - nkwargs.update(kwargs) assert len(DEPENDENCY_KWS) == 20, \ 'Extra kwargs have been added to dependency(), please review if it makes sense to handle it here' - for key, value in nkwargs.items(): - # 'version' is irrelevant for caching; the caller must check version matches - # 'native' is handled above with `for_machine` - # 'required' is irrelevant for caching; the caller handles it separately - # 'fallback' and 'allow_fallback' is not part of the cache because, - # once a dependency has been found through a fallback, it should - # be used for the rest of the Meson run. - # 'default_options' is only used in fallback case - # 'not_found_message' has no impact on the dependency lookup - # 'include_type' is handled after the dependency lookup - if key in {'version', 'native', 'required', 'fallback', 'allow_fallback', 'default_options', - 'not_found_message', 'include_type'}: - continue + # 'version' is irrelevant for caching; the caller must check version matches + # 'native' is handled above with `for_machine` + # 'required' is irrelevant for caching; the caller handles it separately + # 'fallback' and 'allow_fallback' is not part of the cache because, + # once a dependency has been found through a fallback, it should + # be used for the rest of the Meson run. + # 'default_options' is only used in fallback case + # 'not_found_message' has no impact on the dependency lookup + # 'include_type' is handled after the dependency lookup + # 'method' does not matter, we really only want one kind of a dependency + invalid_keys = { + 'version', 'native', 'required', 'fallback', 'allow_fallback', + 'default_options', 'not_found_message', 'include_type'} + valid_keys = [n for n in DEPENDENCY_KWS + if n.name not in invalid_keys] + for dep in valid_keys: + value = kwargs.get(dep.name, dep.default) # All keyword arguments are strings, ints, or lists (or lists of lists) if isinstance(value, list): for i in value: @@ -66,7 +68,7 @@ def get_dep_identifier(name: str, kwargs: T.Dict[str, T.Any]) -> 'TV_DepID': value = tuple(frozenset(listify(value))) else: assert value is None or isinstance(value, (str, bool, int)), value - identifier = (*identifier, (key, value),) + identifier = (*identifier, (dep.name, value),) return identifier display_name_map = {