diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-01-08 16:13:26 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-01-29 09:11:24 -0800 |
commit | 89c67383ccd43eefc9b8c052ec2800a7860bd754 (patch) | |
tree | 13c63161241f501502e909a632a6244a101e069e /mesonbuild/dependencies/misc.py | |
parent | b0f0d30cf3e68c7643b87212b79a54eb691165b8 (diff) | |
download | meson-89c67383ccd43eefc9b8c052ec2800a7860bd754.zip meson-89c67383ccd43eefc9b8c052ec2800a7860bd754.tar.gz meson-89c67383ccd43eefc9b8c052ec2800a7860bd754.tar.bz2 |
dependencies: Use a custom factory for shaderc
Diffstat (limited to 'mesonbuild/dependencies/misc.py')
-rw-r--r-- | mesonbuild/dependencies/misc.py | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index cd4fcb1..c979005 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -18,6 +18,7 @@ from pathlib import Path import functools import re import sysconfig +import typing as T from .. import mlog from .. import mesonlib @@ -27,9 +28,14 @@ from ..mesonlib import listify from .base import ( DependencyException, DependencyMethods, ExternalDependency, PkgConfigDependency, CMakeDependency, ConfigToolDependency, - process_method_kw, DependencyFactory, + process_method_kw, factory_methods, DependencyFactory, ) +if T.TYPE_CHECKING: + from ..environment import Environment, MachineChoice + from .base import DependencyType # noqa: F401 + + class NetCDFDependency(ExternalDependency): def __init__(self, environment, kwargs): @@ -422,32 +428,6 @@ class ShadercDependency(ExternalDependency): def log_tried(self): return 'system' - @classmethod - def _factory(cls, environment, kwargs): - methods = process_method_kw(cls.get_methods(), kwargs) - candidates = [] - - if DependencyMethods.PKGCONFIG in methods: - # ShaderC packages their shared and static libs together - # and provides different pkg-config files for each one. We - # smooth over this difference by handling the static - # keyword before handing off to the pkg-config handler. - shared_libs = ['shaderc'] - static_libs = ['shaderc_combined', 'shaderc_static'] - - if kwargs.get('static', False): - c = [functools.partial(PkgConfigDependency, name, environment, kwargs) - for name in static_libs + shared_libs] - else: - c = [functools.partial(PkgConfigDependency, name, environment, kwargs) - for name in shared_libs + static_libs] - candidates.extend(c) - - if DependencyMethods.SYSTEM in methods: - candidates.append(functools.partial(ShadercDependency, environment, kwargs)) - - return candidates - @staticmethod def get_methods(): return [DependencyMethods.SYSTEM, DependencyMethods.PKGCONFIG] @@ -477,6 +457,39 @@ class CursesDependency(ExternalDependency): return [DependencyMethods.AUTO, DependencyMethods.PKGCONFIG] +@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM}) +def shaderc_factory(env: 'Environment', for_machine: 'MachineChoice', + kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List['DependencyType']: + """Custom DependencyFactory for ShaderC. + + ShaderC's odd you get three different libraries from the same build + thing are just easier to represent as a separate function than + twisting DependencyFactory even more. + """ + candidates = [] # type: T.List['DependencyType'] + + if DependencyMethods.PKGCONFIG in methods: + # ShaderC packages their shared and static libs together + # and provides different pkg-config files for each one. We + # smooth over this difference by handling the static + # keyword before handing off to the pkg-config handler. + shared_libs = ['shaderc'] + static_libs = ['shaderc_combined', 'shaderc_static'] + + if kwargs.get('static', False): + c = [functools.partial(PkgConfigDependency, name, env, kwargs) + for name in static_libs + shared_libs] + else: + c = [functools.partial(PkgConfigDependency, name, env, kwargs) + for name in shared_libs + static_libs] + candidates.extend(c) + + if DependencyMethods.SYSTEM in methods: + candidates.append(functools.partial(ShadercDependency, environment, kwargs)) + + return candidates + + cups_factory = DependencyFactory( 'cups', [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK, DependencyMethods.CMAKE], |