diff options
author | Bruce Richardson <bruce.richardson@intel.com> | 2017-07-27 14:40:25 +0100 |
---|---|---|
committer | Bruce Richardson <bruce.richardson@intel.com> | 2017-08-10 10:37:07 +0100 |
commit | c89b8c5c4b6bec788920e1455ae99cb359280e1d (patch) | |
tree | 0ee7119ae5259bbfe3fd72ea56880a8a3c2436cf /mesonbuild | |
parent | ca4778a50078ae4f1399927111fbeae151178090 (diff) | |
download | meson-c89b8c5c4b6bec788920e1455ae99cb359280e1d.zip meson-c89b8c5c4b6bec788920e1455ae99cb359280e1d.tar.gz meson-c89b8c5c4b6bec788920e1455ae99cb359280e1d.tar.bz2 |
add support for pcap dependencies
Libpcap has its own pcap-config tool rather than using pkg-config. Add
support for pcap-config, based on the existing implementation of
sdl2-config that is there already.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/dependencies/__init__.py | 3 | ||||
-rw-r--r-- | mesonbuild/dependencies/base.py | 2 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 49 |
3 files changed, 53 insertions, 1 deletions
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index c16b92e..61e1080 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -17,7 +17,7 @@ from .base import ( # noqa: F401 ExternalDependency, ExternalLibrary, ExtraFrameworkDependency, InternalDependency, PkgConfigDependency, find_external_dependency, get_dep_identifier, packages, _packages_accept_language) from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency -from .misc import (BoostDependency, MPIDependency, Python3Dependency, ThreadDependency) +from .misc import (BoostDependency, MPIDependency, Python3Dependency, ThreadDependency, PcapDependency) from .platform import AppleFrameworks from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency @@ -34,6 +34,7 @@ packages.update({ 'mpi': MPIDependency, 'python3': Python3Dependency, 'threads': ThreadDependency, + 'pcap': PcapDependency, # From platform: 'appleframeworks': AppleFrameworks, diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 1f18c52..26fc76e 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -44,6 +44,8 @@ class DependencyMethods(Enum): SYSTEM = 'system' # Detect using sdl2-config SDLCONFIG = 'sdlconfig' + # Detect using pcap-config + PCAPCONFIG = 'pcap-config' # This is only supported on OSX - search the frameworks directory by name. EXTRAFRAMEWORK = 'extraframework' # Detect using the sysconfig module. diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index f5cbb96..e9effc6 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -19,10 +19,12 @@ import os import re import shlex import stat +import shutil import sysconfig from .. import mlog from .. import mesonlib +from ..mesonlib import Popen_safe from ..environment import detect_cpu_family from .base import DependencyException, DependencyMethods @@ -574,3 +576,50 @@ class Python3Dependency(ExternalDependency): return [DependencyMethods.PKGCONFIG, DependencyMethods.EXTRAFRAMEWORK] else: return [DependencyMethods.PKGCONFIG] + +class PcapDependency(ExternalDependency): + def __init__(self, environment, kwargs): + super().__init__('pcap', environment, None, kwargs) + if DependencyMethods.PKGCONFIG in self.methods: + try: + kwargs['required'] = False + pcdep = PkgConfigDependency('pcap', environment, kwargs) + if pcdep.found(): + self.type_name = 'pkgconfig' + self.is_found = True + self.compile_args = pcdep.get_compile_args() + self.link_args = pcdep.get_link_args() + self.version = pcdep.get_version() + return + except Exception as e: + mlog.debug('Pcap not found via pkgconfig. Trying next, error was:', str(e)) + if DependencyMethods.PCAPCONFIG in self.methods: + pcapconf = shutil.which('pcap-config') + if pcapconf: + stdo = Popen_safe(['pcap-config', '--cflags'])[1] + self.compile_args = stdo.strip().split() + stdo = Popen_safe(['pcap-config', '--libs'])[1] + self.link_args = stdo.strip().split() + self.version = '0' + self.is_found = True + mlog.log('Dependency', mlog.bold('pcap'), 'found:', + mlog.green('YES'), '(%s)' % pcapconf) + return + mlog.debug('Could not find pcap-config binary, trying next.') + if DependencyMethods.EXTRAFRAMEWORK in self.methods: + if mesonlib.is_osx(): + fwdep = ExtraFrameworkDependency('pcap', False, None, self.env, + self.language, kwargs) + if fwdep.found(): + self.is_found = True + self.compile_args = fwdep.get_compile_args() + self.link_args = fwdep.get_link_args() + self.version = '2' # FIXME + return + mlog.log('Dependency', mlog.bold('pcap'), 'found:', mlog.red('NO')) + + def get_methods(self): + if mesonlib.is_osx(): + return [DependencyMethods.PKGCONFIG, DependencyMethods.PCAPCONFIG, DependencyMethods.EXTRAFRAMEWORK] + else: + return [DependencyMethods.PKGCONFIG, DependencyMethods.PCAPCONFIG] |