diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-01-08 15:43:52 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-01-29 09:11:24 -0800 |
commit | 47502f8adfbec979212f0bfd12d9b086a9117f20 (patch) | |
tree | 8b34edf16f5eac379ab7b5a3527144f721fad774 | |
parent | 0dbe9f6159b427d6688d3b1b39c08584889b6b48 (diff) | |
download | meson-47502f8adfbec979212f0bfd12d9b086a9117f20.zip meson-47502f8adfbec979212f0bfd12d9b086a9117f20.tar.gz meson-47502f8adfbec979212f0bfd12d9b086a9117f20.tar.bz2 |
dependencies: Use DependencyFactory for sdl2
-rw-r--r-- | mesonbuild/dependencies/__init__.py | 4 | ||||
-rw-r--r-- | mesonbuild/dependencies/ui.py | 40 |
2 files changed, 14 insertions, 30 deletions
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index e1fc6c6..62bf558 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -26,7 +26,7 @@ from .mpi import MPIDependency from .scalapack import ScalapackDependency from .misc import (BlocksDependency, CursesDependency, NetCDFDependency, OpenMPDependency, ThreadDependency, ShadercDependency, cups_factory, gpgme_factory, libgcrypt_factory, libwmf_factory, pcap_factory, python3_factory) from .platform import AppleFrameworks -from .ui import GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, gl_factory, vulkan_factory +from .ui import GnuStepDependency, Qt4Dependency, Qt5Dependency, WxDependency, gl_factory, sdl2_factory, vulkan_factory packages.update({ @@ -67,7 +67,7 @@ packages.update({ 'gnustep': GnuStepDependency, 'qt4': Qt4Dependency, 'qt5': Qt5Dependency, - 'sdl2': SDL2Dependency, + 'sdl2': sdl2_factory, 'wxwidgets': WxDependency, 'vulkan': vulkan_factory, }) diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index 02800b8..b633f25 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -14,7 +14,6 @@ # This file contains the detection logic for external dependencies that # are UI-related. -import functools import os import re import subprocess @@ -31,7 +30,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, DependencyFactory +from .base import ConfigToolDependency, DependencyFactory class GLDependencySystem(ExternalDependency): @@ -512,34 +511,13 @@ class Qt5Dependency(QtBaseDependency): return _qt_get_private_includes(mod_inc_dir, module, self.version) -# There are three different ways of depending on SDL2: -# sdl2-config, pkg-config and OSX framework -class SDL2Dependency(ExternalDependency): - def __init__(self, environment, kwargs): - super().__init__('sdl2', environment, kwargs) - - @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, 'sdl2', environment, kwargs)) - - if DependencyMethods.CONFIG_TOOL in methods: - candidates.append(functools.partial(ConfigToolDependency.factory, - 'sdl2', environment, None, - kwargs, ['sdl2-config'], - 'sdl2-config', SDL2Dependency.tool_finish_init)) - - if DependencyMethods.EXTRAFRAMEWORK in methods: - if mesonlib.is_osx(): - candidates.append(functools.partial(ExtraFrameworkDependency, 'sdl2', environment, kwargs)) - # fwdep.version = '2' # FIXME - return candidates +class SDL2DependencyConfigTool(ConfigToolDependency): + + tools = ['sdl2-config'] + tool_name = 'sdl2-config' @staticmethod - def tool_finish_init(ctdep): + def finish_init(ctdep): ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args') @@ -645,6 +623,12 @@ gl_factory = DependencyFactory( system_class=GLDependencySystem, ) +sdl2_factory = DependencyFactory( + 'sdl2', + [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK], + configtool_class=SDL2DependencyConfigTool, +) + vulkan_factory = DependencyFactory( 'vulkan', [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM], |