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.
pull/2130/head
Bruce Richardson 8 years ago
parent ca4778a500
commit c89b8c5c4b
  1. 3
      mesonbuild/dependencies/__init__.py
  2. 2
      mesonbuild/dependencies/base.py
  3. 49
      mesonbuild/dependencies/misc.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,

@ -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.

@ -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]

Loading…
Cancel
Save