diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2021-06-09 15:13:17 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2021-06-16 19:04:03 -0400 |
commit | b6d754a40c618fe280af8f8527add2078a261a72 (patch) | |
tree | f943f54fe685dbb9a039d415f6201c09d8220d35 /mesonbuild/wrap | |
parent | 3970f269fd23c148e94800ca01b6a2d76003a3a2 (diff) | |
download | meson-b6d754a40c618fe280af8f8527add2078a261a72.zip meson-b6d754a40c618fe280af8f8527add2078a261a72.tar.gz meson-b6d754a40c618fe280af8f8527add2078a261a72.tar.bz2 |
interpreter: Extract dependency() logic into its own helper class
The dependency lookup is a lot of complex code. This refactor it all
into a single file/class outside of interpreter main class. This new
design allows adding more fallbacks candidates in the future (e.g. using
cc.find_library()) but does not yet add any extra API.
Diffstat (limited to 'mesonbuild/wrap')
-rw-r--r-- | mesonbuild/wrap/wrap.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 6c5a867..e88d658 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -248,19 +248,19 @@ class Resolver: for k, v in other_resolver.provided_programs.items(): self.provided_programs.setdefault(k, v) - def find_dep_provider(self, packagename: str) -> T.Optional[T.Union[str, T.List[str]]]: + def find_dep_provider(self, packagename: str) -> T.Tuple[T.Optional[str], T.Optional[str]]: # Python's ini parser converts all key values to lowercase. # Thus the query name must also be in lower case. packagename = packagename.lower() - # Return value is in the same format as fallback kwarg: - # ['subproject_name', 'variable_name'], or 'subproject_name'. wrap = self.provided_deps.get(packagename) if wrap: dep_var = wrap.provided_deps.get(packagename) - if dep_var: - return [wrap.name, dep_var] - return wrap.name - return None + return wrap.name, dep_var + return None, None + + def get_varname(self, subp_name: str, depname: str) -> T.Optional[str]: + wrap = self.wraps.get(subp_name) + return wrap.provided_deps.get(depname) if wrap else None def find_program_provider(self, names: T.List[str]) -> T.Optional[str]: for name in names: |