diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-08-15 21:03:07 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2023-09-18 13:51:27 -0400 |
commit | dec85c41a9e5d6f8bb2c4431a78a0a9ade3651fd (patch) | |
tree | a48a2884201f444833d74aec8f352924c77b644a /mesonbuild/dependencies | |
parent | 30d7f506c7ffe4af52feab1a68263a4bd8d78c8a (diff) | |
download | meson-dec85c41a9e5d6f8bb2c4431a78a0a9ade3651fd.zip meson-dec85c41a9e5d6f8bb2c4431a78a0a9ade3651fd.tar.gz meson-dec85c41a9e5d6f8bb2c4431a78a0a9ade3651fd.tar.bz2 |
Remove get_configtool_variable()
This also makes it more consistent with get_pkgconfig_variable() which
always return empty value instead of failing when the variable does not
exist. Linking that to self.required makes no sense and was never
documented any way.
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r-- | mesonbuild/dependencies/base.py | 7 | ||||
-rw-r--r-- | mesonbuild/dependencies/configtool.py | 28 |
2 files changed, 5 insertions, 30 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 6da9a66..c4861ff 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -193,9 +193,6 @@ class Dependency(HoldableObject): def get_exe_args(self, compiler: 'Compiler') -> T.List[str]: return [] - def get_configtool_variable(self, variable_name: str) -> str: - raise DependencyException(f'{self.name!r} is not a config-tool dependency') - def get_partial_dependency(self, *, compile_args: bool = False, link_args: bool = False, links: bool = False, includes: bool = False, sources: bool = False) -> 'Dependency': @@ -292,10 +289,6 @@ class InternalDependency(Dependency): return True return any(d.is_built() for d in self.ext_deps) - def get_configtool_variable(self, variable_name: str) -> str: - raise DependencyException('Method "get_configtool_variable()" is ' - 'invalid for an internal dependency') - def get_partial_dependency(self, *, compile_args: bool = False, link_args: bool = False, links: bool = False, includes: bool = False, sources: bool = False, diff --git a/mesonbuild/dependencies/configtool.py b/mesonbuild/dependencies/configtool.py index bd6a9ff..3c52356 100644 --- a/mesonbuild/dependencies/configtool.py +++ b/mesonbuild/dependencies/configtool.py @@ -154,17 +154,6 @@ class ConfigToolDependency(ExternalDependency): def get_variable_args(self, variable_name: str) -> T.List[str]: return [f'--{variable_name}'] - def get_configtool_variable(self, variable_name: str) -> str: - p, out, _ = Popen_safe(self.config + self.get_variable_args(variable_name)) - if p.returncode != 0: - if self.required: - raise DependencyException( - 'Could not get variable "{}" for dependency {}'.format( - variable_name, self.name)) - variable = out.strip() - mlog.debug(f'Got config-tool variable {variable_name} : {variable}') - return variable - @staticmethod def log_tried() -> str: return 'config-tool' @@ -174,18 +163,11 @@ class ConfigToolDependency(ExternalDependency): default_value: T.Optional[str] = None, pkgconfig_define: PkgConfigDefineType = None) -> str: if configtool: - # In the not required case '' (empty string) will be returned if the - # variable is not found. Since '' is a valid value to return we - # set required to True here to force and error, and use the - # finally clause to ensure it's restored. - restore = self.required - self.required = True - try: - return self.get_configtool_variable(configtool) - except DependencyException: - pass - finally: - self.required = restore + p, out, _ = Popen_safe(self.config + self.get_variable_args(configtool)) + if p.returncode == 0: + variable = out.strip() + mlog.debug(f'Got config-tool variable {configtool} : {variable}') + return variable if default_value is not None: return default_value raise DependencyException(f'Could not get config-tool variable and no default provided for {self!r}') |