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