diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-01-08 14:27:02 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-01-29 09:11:24 -0800 |
commit | 309d30a9c2ca16170bd972e6f930247e4e5cfe4c (patch) | |
tree | 52ee373a7fba1fd49a22654da5b4f627ef188445 | |
parent | bc2bfcacbd625905530a3b700a25298e985562a4 (diff) | |
download | meson-309d30a9c2ca16170bd972e6f930247e4e5cfe4c.zip meson-309d30a9c2ca16170bd972e6f930247e4e5cfe4c.tar.gz meson-309d30a9c2ca16170bd972e6f930247e4e5cfe4c.tar.bz2 |
dependencies: Use DependencyFactory for libpcap
-rw-r--r-- | mesonbuild/dependencies/__init__.py | 5 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 51 |
2 files changed, 23 insertions, 33 deletions
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index e7342af..9d8dcf2 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -24,8 +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, Python3Dependency, ThreadDependency, - PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency, GpgmeDependency, ShadercDependency) +from .misc import (BlocksDependency, CursesDependency, NetCDFDependency, OpenMPDependency, Python3Dependency, ThreadDependency, CupsDependency, LibWmfDependency, LibGCryptDependency, GpgmeDependency, ShadercDependency, pcap_factory) from .platform import AppleFrameworks from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, vulkan_factory @@ -53,7 +52,7 @@ packages.update({ 'openmp': OpenMPDependency, 'python3': Python3Dependency, 'threads': ThreadDependency, - 'pcap': PcapDependency, + 'pcap': pcap_factory, 'cups': CupsDependency, 'libwmf': LibWmfDependency, 'libgcrypt': LibGCryptDependency, diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index d4a505d..cef726f 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -28,9 +28,9 @@ from .base import ( DependencyException, DependencyMethods, ExternalDependency, ExtraFrameworkDependency, PkgConfigDependency, CMakeDependency, ConfigToolDependency, process_method_kw, + DependencyFactory, ) - class NetCDFDependency(ExternalDependency): def __init__(self, environment, kwargs): @@ -323,47 +323,29 @@ class Python3Dependency(ExternalDependency): def log_tried(self): return 'sysconfig' -class PcapDependency(ExternalDependency): - - def __init__(self, environment, kwargs): - super().__init__('pcap', 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, 'pcap', environment, kwargs)) - - if DependencyMethods.CONFIG_TOOL in methods: - candidates.append(functools.partial(ConfigToolDependency.factory, - 'pcap', environment, None, - kwargs, ['pcap-config'], - 'pcap-config', - PcapDependency.tool_finish_init)) +class PcapDependencyConfigTool(ConfigToolDependency): - return candidates + tools = ['pcap-config'] + tool_name = 'pcap-config' @staticmethod - def tool_finish_init(ctdep): - ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') - ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args') - ctdep.version = PcapDependency.get_pcap_lib_version(ctdep) + def finish_init(self) -> None: + self.compile_args = self.get_config_value(['--cflags'], 'compile_args') + self.link_args = self.get_config_value(['--libs'], 'link_args') + self.version = self.get_pcap_lib_version() @staticmethod def get_methods(): return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL] - @staticmethod - def get_pcap_lib_version(ctdep): + def get_pcap_lib_version(self): # Since we seem to need to run a program to discover the pcap version, # we can't do that when cross-compiling - if not ctdep.env.machines.matches_build_machine(ctdep.for_machine): + if not self.env.machines.matches_build_machine(self.for_machine): return None - v = ctdep.clib_compiler.get_return_value('pcap_lib_version', 'string', - '#include <pcap.h>', ctdep.env, [], [ctdep]) + v = self.clib_compiler.get_return_value('pcap_lib_version', 'string', + '#include <pcap.h>', self.env, [], [self]) v = re.sub(r'libpcap version ', '', v) v = re.sub(r' -- Apple version.*$', '', v) return v @@ -558,6 +540,7 @@ class ShadercDependency(ExternalDependency): def get_methods(): return [DependencyMethods.SYSTEM, DependencyMethods.PKGCONFIG] + class CursesDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('curses', environment, None, kwargs) @@ -580,3 +563,11 @@ class CursesDependency(ExternalDependency): @staticmethod def get_methods(): return [DependencyMethods.AUTO, DependencyMethods.PKGCONFIG] + + +pcap_factory = DependencyFactory( + 'pcap', + [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL], + configtool_class=PcapDependencyConfigTool, + pkgconfig_name='libpcap', +) |