aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/dependencies/__init__.py4
-rw-r--r--mesonbuild/dependencies/misc.py67
2 files changed, 42 insertions, 29 deletions
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py
index 62bf558..c3d03cb 100644
--- a/mesonbuild/dependencies/__init__.py
+++ b/mesonbuild/dependencies/__init__.py
@@ -24,7 +24,7 @@ from .dev import ValgrindDependency, gmock_factory, gtest_factory, llvm_factory
from .coarrays import CoarrayDependency
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 .misc import (BlocksDependency, CursesDependency, NetCDFDependency, OpenMPDependency, ThreadDependency, cups_factory, gpgme_factory, libgcrypt_factory, libwmf_factory, pcap_factory, python3_factory, shaderc_factory)
from .platform import AppleFrameworks
from .ui import GnuStepDependency, Qt4Dependency, Qt5Dependency, WxDependency, gl_factory, sdl2_factory, vulkan_factory
@@ -57,7 +57,7 @@ packages.update({
'libwmf': libwmf_factory,
'libgcrypt': libgcrypt_factory,
'gpgme': gpgme_factory,
- 'shaderc': ShadercDependency,
+ 'shaderc': shaderc_factory,
# From platform:
'appleframeworks': AppleFrameworks,
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],