Add shaderc dependency lookup logic

This commit is contained in:
Andrei Alexeyev 2019-04-02 22:47:10 +03:00 committed by Jussi Pakkanen
parent 38273ac668
commit 8209180c76
3 changed files with 61 additions and 1 deletions

View File

@ -483,6 +483,18 @@ Meson substitutes `modules` to `wx-config` invocation, it generates
- `compile_args` using `wx-config --cxxflags $modules...`
- `link_args` using `wx-config --libs $modules...`
## Shaderc
*(added 0.51.0)*
Shaderc currently does not ship with any means of detection. Nevertheless, Meson
can try to detect it using `pkg-config`, but will default to looking for the
appropriate library manually. If the `static` keyword argument is `true`,
`shaderc_combined` is preferred. Otherwise, `shaderc_shared` is preferred. Note
that it is not possible to obtain the shaderc version using this method.
`method` may be `auto`, `pkg-config` or `system`.
### Example
```meson

View File

@ -18,7 +18,7 @@ from .base import ( # noqa: F401
ExternalDependency, NotFoundDependency, ExternalLibrary, ExtraFrameworkDependency, InternalDependency,
PkgConfigDependency, CMakeDependency, find_external_dependency, get_dep_identifier, packages, _packages_accept_language)
from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency
from .misc import (CoarrayDependency, HDF5Dependency, MPIDependency, NetCDFDependency, OpenMPDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency)
from .misc import (CoarrayDependency, HDF5Dependency, MPIDependency, NetCDFDependency, OpenMPDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency, ShadercDependency)
from .platform import AppleFrameworks
from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency
@ -43,6 +43,7 @@ packages.update({
'cups': CupsDependency,
'libwmf': LibWmfDependency,
'libgcrypt': LibGCryptDependency,
'shaderc': ShadercDependency,
# From platform:
'appleframeworks': AppleFrameworks,

View File

@ -117,6 +117,7 @@ class HDF5Dependency(ExternalDependency):
except Exception:
pass
class NetCDFDependency(ExternalDependency):
def __init__(self, environment, kwargs):
@ -666,3 +667,49 @@ class LibGCryptDependency(ExternalDependency):
@staticmethod
def get_methods():
return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL]
class ShadercDependency(ExternalDependency):
def __init__(self, environment, kwargs):
super().__init__('shaderc', environment, None, kwargs)
static_lib = 'shaderc_combined'
shared_lib = 'shaderc_shared'
libs = [shared_lib, static_lib]
if self.static:
libs.reverse()
cc = self.get_compiler()
for lib in libs:
self.link_args = cc.find_library(lib, environment, [])
if self.link_args is not None:
self.is_found = True
if self.static and lib != static_lib:
mlog.warning('Static library {!r} not found for dependency {!r}, may '
'not be statically linked'.format(static_lib, self.name))
break
def log_tried(self):
return 'system'
@classmethod
def _factory(cls, environment, kwargs):
methods = cls._process_method_kw(kwargs)
candidates = []
if DependencyMethods.SYSTEM in methods:
candidates.append(functools.partial(ShadercDependency, environment, kwargs))
if DependencyMethods.PKGCONFIG in methods:
candidates.append(functools.partial(PkgConfigDependency, 'shaderc', environment, kwargs))
return candidates
@staticmethod
def get_methods():
return [DependencyMethods.SYSTEM, DependencyMethods.PKGCONFIG]