Use ConfigToolDependency for pcap
This commit is contained in:
parent
a2f3182172
commit
11fbc982d3
|
@ -46,8 +46,6 @@ class DependencyMethods(Enum):
|
|||
QMAKE = 'qmake'
|
||||
# Just specify the standard link arguments, assuming the operating system provides the library.
|
||||
SYSTEM = 'system'
|
||||
# Detect using pcap-config
|
||||
PCAPCONFIG = 'pcap-config'
|
||||
# Detect using libwmf-config
|
||||
LIBWMFCONFIG = 'libwmf-config'
|
||||
# This is only supported on OSX - search the frameworks directory by name.
|
||||
|
@ -59,6 +57,7 @@ class DependencyMethods(Enum):
|
|||
# For backewards compatibility
|
||||
SDLCONFIG = 'sdlconfig'
|
||||
CUPSCONFIG = 'cups-config'
|
||||
PCAPCONFIG = 'pcap-config'
|
||||
|
||||
|
||||
class Dependency:
|
||||
|
@ -78,7 +77,8 @@ class Dependency:
|
|||
|
||||
# This sets per-too config methods which are deprecated to to the new
|
||||
# generic CONFIG_TOOL value.
|
||||
if method in [DependencyMethods.SDLCONFIG, DependencyMethods.CUPSCONFIG]:
|
||||
if method in [DependencyMethods.SDLCONFIG, DependencyMethods.CUPSCONFIG,
|
||||
DependencyMethods.PCAPCONFIG]:
|
||||
mlog.warning(textwrap.dedent("""\
|
||||
Configuration method {} has been deprecated in favor of
|
||||
'config-tool'. This will be removed in a future version of
|
||||
|
|
|
@ -26,8 +26,11 @@ from .. import mesonlib
|
|||
from ..mesonlib import Popen_safe, extract_as_list
|
||||
from ..environment import detect_cpu_family
|
||||
|
||||
from .base import DependencyException, DependencyMethods
|
||||
from .base import ExternalDependency, ExternalProgram, ExtraFrameworkDependency, PkgConfigDependency
|
||||
from .base import (
|
||||
DependencyException, DependencyMethods, ExternalDependency,
|
||||
ExternalProgram, ExtraFrameworkDependency, PkgConfigDependency,
|
||||
ConfigToolDependency,
|
||||
)
|
||||
|
||||
# On windows 3 directory layouts are supported:
|
||||
# * The default layout (versioned) installed:
|
||||
|
@ -687,9 +690,9 @@ class Python3Dependency(ExternalDependency):
|
|||
class PcapDependency(ExternalDependency):
|
||||
def __init__(self, environment, kwargs):
|
||||
super().__init__('pcap', environment, None, kwargs)
|
||||
kwargs['required'] = False
|
||||
if DependencyMethods.PKGCONFIG in self.methods:
|
||||
try:
|
||||
kwargs['required'] = False
|
||||
pcdep = PkgConfigDependency('pcap', environment, kwargs)
|
||||
if pcdep.found():
|
||||
self.type_name = 'pkgconfig'
|
||||
|
@ -700,25 +703,26 @@ class PcapDependency(ExternalDependency):
|
|||
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 = self.get_pcap_lib_version()
|
||||
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.CONFIG_TOOL in self.methods:
|
||||
try:
|
||||
ctdep = ConfigToolDependency.factory(
|
||||
'pcap', environment, None, kwargs, ['pcap-config'], 'pcap-config')
|
||||
if ctdep.found():
|
||||
self.config = ctdep.config
|
||||
self.type_name = 'config-tool'
|
||||
self.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
|
||||
self.link_args = ctdep.get_config_value(['--libs'], 'link_args')
|
||||
self.version = self.get_pcap_lib_version()
|
||||
self.is_found = True
|
||||
return
|
||||
except Exception as e:
|
||||
mlog.debug('Pcap not found via pcap-config. Trying next, error was:', str(e))
|
||||
|
||||
def get_methods(self):
|
||||
if mesonlib.is_osx():
|
||||
return [DependencyMethods.PKGCONFIG, DependencyMethods.PCAPCONFIG, DependencyMethods.EXTRAFRAMEWORK]
|
||||
return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK]
|
||||
else:
|
||||
return [DependencyMethods.PKGCONFIG, DependencyMethods.PCAPCONFIG]
|
||||
return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL]
|
||||
|
||||
def get_pcap_lib_version(self):
|
||||
return self.compiler.get_return_value('pcap_lib_version', 'string',
|
||||
|
|
|
@ -8,3 +8,7 @@ assert(pcap_ver.split('.').length() > 1, 'pcap version is "@0@"'.format(pcap_ver
|
|||
e = executable('pcap_prog', 'pcap_prog.c', dependencies : pcap_dep)
|
||||
|
||||
test('pcaptest', e)
|
||||
|
||||
# Ensure discovery bia the configuration tools work also
|
||||
pcap_dep = dependency('pcap', version : '>=1.0', method : 'pcap-config')
|
||||
pcap_dep = dependency('pcap', version : '>=1.0', method : 'config-tool')
|
||||
|
|
Loading…
Reference in New Issue