diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-01-07 16:02:14 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-01-29 09:11:24 -0800 |
commit | c17fa3223f948742d802b4032f6b6a79a8542357 (patch) | |
tree | d9b0161c9763d2af11fc2946f433195c57fdb776 | |
parent | 29b6d3e63ce6b18fa159a9d36de77c4f78c8bcc9 (diff) | |
download | meson-c17fa3223f948742d802b4032f6b6a79a8542357.zip meson-c17fa3223f948742d802b4032f6b6a79a8542357.tar.gz meson-c17fa3223f948742d802b4032f6b6a79a8542357.tar.bz2 |
dependencies: Use DependencyFactory for Vulkan
-rw-r--r-- | mesonbuild/dependencies/__init__.py | 4 | ||||
-rw-r--r-- | mesonbuild/dependencies/ui.py | 30 |
2 files changed, 14 insertions, 20 deletions
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index 4393ed6..14b7cba 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -27,7 +27,7 @@ from .scalapack import ScalapackDependency from .misc import (BlocksDependency, CursesDependency, NetCDFDependency, OpenMPDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency, GpgmeDependency, ShadercDependency) from .platform import AppleFrameworks -from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency +from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, vulkan_factory packages.update({ @@ -70,7 +70,7 @@ packages.update({ 'qt5': Qt5Dependency, 'sdl2': SDL2Dependency, 'wxwidgets': WxDependency, - 'vulkan': VulkanDependency, + 'vulkan': vulkan_factory, }) _packages_accept_language.update({ 'hdf5', diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index 38c51b8..016e324 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -31,7 +31,7 @@ from ..environment import detect_cpu_family from .base import DependencyException, DependencyMethods from .base import ExternalDependency, ExternalProgram, NonExistingExternalProgram from .base import ExtraFrameworkDependency, PkgConfigDependency -from .base import ConfigToolDependency, process_method_kw +from .base import ConfigToolDependency, process_method_kw, DependencyFactory class GLDependency(ExternalDependency): @@ -589,10 +589,10 @@ class WxDependency(ConfigToolDependency): return candidates -class VulkanDependency(ExternalDependency): +class VulkanDependencySystem(ExternalDependency): - def __init__(self, environment, kwargs): - super().__init__('vulkan', environment, kwargs) + def __init__(self, name: str, environment, kwargs, language: T.Optional[str] = None): + super().__init__(name, environment, kwargs, language=language) try: self.vulkan_sdk = os.environ['VULKAN_SDK'] @@ -645,22 +645,16 @@ class VulkanDependency(ExternalDependency): self.link_args.append(lib) return - @classmethod - def _factory(cls, environment, kwargs): - methods = process_method_kw(cls.get_methods(), kwargs) - candidates = [] - - if DependencyMethods.PKGCONFIG in methods: - candidates.append(functools.partial(PkgConfigDependency, 'vulkan', environment, kwargs)) - - if DependencyMethods.SYSTEM in methods: - candidates.append(functools.partial(VulkanDependency, environment, kwargs)) - - return candidates - @staticmethod def get_methods(): - return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] + return [DependencyMethods.SYSTEM] def log_tried(self): return 'system' + + +vulkan_factory = DependencyFactory( + 'vulkan', + [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM], + system_class=VulkanDependencySystem, +) |