diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2017-10-19 00:24:52 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2017-11-23 19:54:48 -0800 |
commit | 11fbc982d3fcb95b6774e0af6cc7d506fe876dc0 (patch) | |
tree | 7a2b2ec2af0797d53cdce435f9c83fad444ff65f | |
parent | a2f31821723d1e7bd445b73c58ec733c199be9d2 (diff) | |
download | meson-11fbc982d3fcb95b6774e0af6cc7d506fe876dc0.tar.gz |
Use ConfigToolDependency for pcap
-rw-r--r-- | mesonbuild/dependencies/base.py | 6 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 40 | ||||
-rw-r--r-- | test cases/frameworks/19 pcap/meson.build | 4 |
3 files changed, 29 insertions, 21 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 46d0a993e..3dcb41a48 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -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 diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index cae88429a..f627e0199 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -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', diff --git a/test cases/frameworks/19 pcap/meson.build b/test cases/frameworks/19 pcap/meson.build index c5059602a..f02f4114b 100644 --- a/test cases/frameworks/19 pcap/meson.build +++ b/test cases/frameworks/19 pcap/meson.build @@ -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') |