diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-08-13 22:46:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-13 22:46:23 +0300 |
commit | 8c8e9230a532196da0072e82df1452fa8486176b (patch) | |
tree | 883042e2cbb8cbedb14a782fbd64337713aebb79 /mesonbuild | |
parent | 0ad448f89009e87fc3f22a85b0af53de5ebf8355 (diff) | |
parent | 0a6f848aa3ed632d584bce8f9b91bce65ceac971 (diff) | |
download | meson-8c8e9230a532196da0072e82df1452fa8486176b.zip meson-8c8e9230a532196da0072e82df1452fa8486176b.tar.gz meson-8c8e9230a532196da0072e82df1452fa8486176b.tar.bz2 |
Merge pull request #2130 from bruce-richardson/pcap_config_support
add support for pcap dependencies
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] |