From dd97ec607d9ae073cb5d07da5b7e476afbfc0a0d Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 13 Jul 2021 13:22:39 -0700 Subject: [PATCH] dependencies: drop Dependency.methods and Dependency.get_methods() Both of these are artifacts of the time before Dependency Factories, when a dependency that could be discovered multiple ways did ugly stuff like finding a specific dependency, then replacing it's own attributes with that dependency's attributes. We don't have cases of that left in the tree, so let's get rid of this code too --- mesonbuild/dependencies/base.py | 13 -------- mesonbuild/dependencies/cmake.py | 6 +--- mesonbuild/dependencies/coarrays.py | 4 --- mesonbuild/dependencies/configtool.py | 6 +--- mesonbuild/dependencies/dev.py | 17 ----------- mesonbuild/dependencies/dub.py | 6 +--- mesonbuild/dependencies/framework.py | 6 +--- mesonbuild/dependencies/misc.py | 44 --------------------------- mesonbuild/dependencies/pkgconfig.py | 6 +--- mesonbuild/dependencies/ui.py | 18 ----------- 10 files changed, 5 insertions(+), 121 deletions(-) diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 2ecc90996..7d6bf625e 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -89,7 +89,6 @@ class Dependency(HoldableObject): # If None, self.link_args will be used self.raw_link_args: T.Optional[T.List[str]] = None self.sources: T.List['FileOrString'] = [] - self.methods = process_method_kw(self.get_methods(), kwargs) self.include_type = self._process_include_type_kw(kwargs) self.ext_deps: T.List[Dependency] = [] @@ -148,10 +147,6 @@ class Dependency(HoldableObject): As an example, gtest-all.cc when using GTest.""" return self.sources - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.AUTO] - def get_name(self) -> str: return self.name @@ -547,10 +542,6 @@ class SystemDependency(ExternalDependency): super().__init__(DependencyTypeName('system'), env, kwargs, language=language) self.name = name - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.SYSTEM] - def log_tried(self) -> str: return 'system' @@ -564,9 +555,5 @@ class BuiltinDependency(ExternalDependency): super().__init__(DependencyTypeName('builtin'), env, kwargs, language=language) self.name = name - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.BUILTIN] - def log_tried(self) -> str: return 'builtin' diff --git a/mesonbuild/dependencies/cmake.py b/mesonbuild/dependencies/cmake.py index 8219cc5ef..ed89622b3 100644 --- a/mesonbuild/dependencies/cmake.py +++ b/mesonbuild/dependencies/cmake.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .base import ExternalDependency, DependencyException, DependencyMethods, DependencyTypeName +from .base import ExternalDependency, DependencyException, DependencyTypeName from ..mesonlib import is_windows, MesonException, OptionKey, PerMachine, stringlistify, extract_as_list from ..mesondata import mesondata from ..cmake import CMakeExecutor, CMakeTraceParser, CMakeException, CMakeToolchain, CMakeExecScope, check_cmake_args @@ -632,10 +632,6 @@ class CMakeDependency(ExternalDependency): build_dir = self._setup_cmake_dir(cmake_file) return self.cmakebin.call(args, build_dir, env=env) - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.CMAKE] - def log_tried(self) -> str: return self.type_name diff --git a/mesonbuild/dependencies/coarrays.py b/mesonbuild/dependencies/coarrays.py index d9af191a7..b50fb0aa5 100644 --- a/mesonbuild/dependencies/coarrays.py +++ b/mesonbuild/dependencies/coarrays.py @@ -84,7 +84,3 @@ class CoarrayDependency(SystemDependency): elif cid == 'nagfor': # NAG doesn't require any special arguments for Coarray self.is_found = True - - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.AUTO, DependencyMethods.CMAKE, DependencyMethods.PKGCONFIG] diff --git a/mesonbuild/dependencies/configtool.py b/mesonbuild/dependencies/configtool.py index 623affb2c..7dccee4b6 100644 --- a/mesonbuild/dependencies/configtool.py +++ b/mesonbuild/dependencies/configtool.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .base import ExternalDependency, DependencyException, DependencyMethods, DependencyTypeName +from .base import ExternalDependency, DependencyException, DependencyTypeName from ..mesonlib import listify, Popen_safe, split_args, version_compare, version_compare_many from ..programs import find_external_program from .. import mlog @@ -138,10 +138,6 @@ class ConfigToolDependency(ExternalDependency): return [] return split_args(out) - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.AUTO, DependencyMethods.CONFIG_TOOL] - def get_configtool_variable(self, variable_name: str) -> str: p, out, _ = Popen_safe(self.config + [f'--{variable_name}']) if p.returncode != 0: diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 7300e2fe7..9c2594fb1 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -106,10 +106,6 @@ class GTestDependencySystem(SystemDependency): def log_tried(self) -> str: return 'system' - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] - class GTestDependencyPC(PkgConfigDependency): @@ -181,10 +177,6 @@ class GMockDependencySystem(SystemDependency): def log_tried(self) -> str: return 'system' - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] - class GMockDependencyPC(PkgConfigDependency): @@ -508,11 +500,6 @@ class ZlibSystemDependency(SystemDependency): self.version = v.strip('"') - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.SYSTEM] - - class JDKSystemDependency(SystemDependency): def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]): super().__init__('jdk', environment, kwargs) @@ -544,10 +531,6 @@ class JDKSystemDependency(SystemDependency): self.compile_args.append(f'-I{java_home_include / platform_include_dir}') self.is_found = True - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.SYSTEM] - @staticmethod def __machine_info_to_platform_include_dir(m: 'MachineInfo') -> T.Optional[str]: """Translates the machine information to the platform-dependent include directory diff --git a/mesonbuild/dependencies/dub.py b/mesonbuild/dependencies/dub.py index 8dfb4869d..6aebe7b59 100644 --- a/mesonbuild/dependencies/dub.py +++ b/mesonbuild/dependencies/dub.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .base import ExternalDependency, DependencyException, DependencyMethods, DependencyTypeName +from .base import ExternalDependency, DependencyException, DependencyTypeName from .pkgconfig import PkgConfigDependency from ..mesonlib import Popen_safe from ..programs import ExternalProgram @@ -234,7 +234,3 @@ class DubDependency(ExternalDependency): else: mlog.log('Found DUB:', mlog.red('NO')) return dubbin - - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.DUB] diff --git a/mesonbuild/dependencies/framework.py b/mesonbuild/dependencies/framework.py index 48223987e..3a947f0c1 100644 --- a/mesonbuild/dependencies/framework.py +++ b/mesonbuild/dependencies/framework.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .base import DependencyTypeName, ExternalDependency, DependencyException, DependencyMethods +from .base import DependencyTypeName, ExternalDependency, DependencyException from ..mesonlib import MesonException, Version, stringlistify from .. import mlog from pathlib import Path @@ -112,10 +112,6 @@ class ExtraFrameworkDependency(ExternalDependency): return trial.as_posix() return None - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.EXTRAFRAMEWORK] - def log_info(self) -> str: return self.framework_path or '' diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 483212f96..9aa26c2af 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -125,10 +125,6 @@ class ThreadDependency(SystemDependency): self.compile_args = self.clib_compiler.thread_flags(environment) self.link_args = self.clib_compiler.thread_link_flags(environment) - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.AUTO, DependencyMethods.CMAKE] - class BlocksDependency(SystemDependency): def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]) -> None: @@ -262,15 +258,6 @@ class Python3DependencySystem(SystemDependency): self.version = sysconfig.get_config_var('py_version') self.is_found = True - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - if mesonlib.is_windows(): - return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSCONFIG] - elif mesonlib.is_osx(): - return [DependencyMethods.PKGCONFIG, DependencyMethods.EXTRAFRAMEWORK] - else: - return [DependencyMethods.PKGCONFIG] - def log_tried(self) -> str: return 'sysconfig' @@ -287,10 +274,6 @@ class PcapDependencyConfigTool(ConfigToolDependency): self.link_args = self.get_config_value(['--libs'], 'link_args') self.version = self.get_pcap_lib_version() - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL] - def get_pcap_lib_version(self) -> T.Optional[str]: # Since we seem to need to run a program to discover the pcap version, # we can't do that when cross-compiling @@ -317,13 +300,6 @@ class CupsDependencyConfigTool(ConfigToolDependency): self.compile_args = self.get_config_value(['--cflags'], 'compile_args') self.link_args = self.get_config_value(['--ldflags', '--libs'], 'link_args') - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - if mesonlib.is_osx(): - return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK, DependencyMethods.CMAKE] - else: - return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.CMAKE] - class LibWmfDependencyConfigTool(ConfigToolDependency): @@ -337,10 +313,6 @@ class LibWmfDependencyConfigTool(ConfigToolDependency): self.compile_args = self.get_config_value(['--cflags'], 'compile_args') self.link_args = self.get_config_value(['--libs'], 'link_args') - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL] - class LibGCryptDependencyConfigTool(ConfigToolDependency): @@ -355,10 +327,6 @@ class LibGCryptDependencyConfigTool(ConfigToolDependency): self.link_args = self.get_config_value(['--libs'], 'link_args') self.version = self.get_config_value(['--version'], 'version')[0] - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL] - class GpgmeDependencyConfigTool(ConfigToolDependency): @@ -373,10 +341,6 @@ class GpgmeDependencyConfigTool(ConfigToolDependency): self.link_args = self.get_config_value(['--libs'], 'link_args') self.version = self.get_config_value(['--version'], 'version')[0] - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL] - class ShadercDependency(SystemDependency): @@ -406,10 +370,6 @@ class ShadercDependency(SystemDependency): def log_tried(self) -> str: return 'system' - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.SYSTEM, DependencyMethods.PKGCONFIG] - class CursesConfigToolDependency(ConfigToolDependency): @@ -481,10 +441,6 @@ class CursesSystemDependency(SystemDependency): if self.is_found: break - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.SYSTEM] - class IntlBuiltinDependency(BuiltinDependency): def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py index 1e8d9132e..28a3f7467 100644 --- a/mesonbuild/dependencies/pkgconfig.py +++ b/mesonbuild/dependencies/pkgconfig.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .base import ExternalDependency, DependencyException, DependencyMethods, sort_libpaths, DependencyTypeName +from .base import ExternalDependency, DependencyException, sort_libpaths, DependencyTypeName from ..mesonlib import LibType, MachineChoice, OptionKey, OrderedSet, PerMachine, Popen_safe from ..programs import find_external_program, ExternalProgram from .. import mlog @@ -396,10 +396,6 @@ class PkgConfigDependency(ExternalDependency): mlog.debug(f'Got pkgconfig variable {variable_name} : {variable}') return variable - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.PKGCONFIG] - def check_pkgconfig(self, pkgbin: ExternalProgram) -> T.Optional[str]: if not pkgbin.found(): mlog.log(f'Did not find pkg-config by name {pkgbin.name!r}') diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index f256a370c..530a1011b 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -50,13 +50,6 @@ class GLDependencySystem(SystemDependency): # FIXME: Detect version using self.clib_compiler return - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - if mesonlib.is_osx() or mesonlib.is_windows(): - return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] - else: - return [DependencyMethods.PKGCONFIG] - def log_tried(self) -> str: return 'system' @@ -149,13 +142,6 @@ class SDL2DependencyConfigTool(ConfigToolDependency): self.compile_args = self.get_config_value(['--cflags'], 'compile_args') self.link_args = self.get_config_value(['--libs'], 'link_args') - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - if mesonlib.is_osx(): - return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK] - else: - return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL] - class WxDependency(ConfigToolDependency): @@ -251,10 +237,6 @@ class VulkanDependencySystem(SystemDependency): self.link_args.append(lib) return - @staticmethod - def get_methods() -> T.List[DependencyMethods]: - return [DependencyMethods.SYSTEM] - def log_tried(self) -> str: return 'system'