dependencies: fix pcap-config which now errors on --version

The latest release of libpcap added argument validation to pcap-config,
but still doesn't support --version. The next version of libpcap will
support --version.

Add support for config-tool dependencies which expect to break on
--version, to fallback to an option that does not error out or print
version info, for sanity checking.
pull/11288/head
Eli Schwartz 2 years ago
parent c49552ffb2
commit 921ddb1980
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 12
      mesonbuild/dependencies/configtool.py
  2. 8
      mesonbuild/dependencies/misc.py

@ -31,6 +31,9 @@ class ConfigToolDependency(ExternalDependency):
Takes the following extra keys in kwargs that it uses internally:
:tools List[str]: A list of tool names to use
:version_arg str: The argument to pass to the tool to get it's version
:skip_version str: The argument to pass to the tool to ignore its version
(if ``version_arg`` fails, but it may start accepting it in the future)
Because some tools are stupid and don't accept --version
:returncode_value int: The value of the correct returncode
Because some tools are stupid and don't return 0
"""
@ -38,6 +41,7 @@ class ConfigToolDependency(ExternalDependency):
tools: T.Optional[T.List[str]] = None
tool_name: T.Optional[str] = None
version_arg = '--version'
skip_version: T.Optional[str] = None
__strip_version = re.compile(r'^[0-9][0-9.]+')
def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None):
@ -89,7 +93,13 @@ class ConfigToolDependency(ExternalDependency):
except (FileNotFoundError, PermissionError):
continue
if p.returncode != returncode:
continue
if self.skip_version:
# maybe the executable is valid even if it doesn't support --version
p = Popen_safe(tool + [self.skip_version])[0]
if p.returncode != returncode:
continue
else:
continue
out = self._sanitize_version(out.strip())
# Some tools, like pcap-config don't supply a version, but also

@ -293,13 +293,19 @@ class PcapDependencyConfigTool(ConfigToolDependency):
tools = ['pcap-config']
tool_name = 'pcap-config'
# version 1.10.2 added error checking for invalid arguments
# version 1.10.3 will hopefully add actual support for --version
skip_version = '--help'
def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]):
super().__init__(name, environment, kwargs)
if not self.is_found:
return
self.compile_args = self.get_config_value(['--cflags'], 'compile_args')
self.link_args = self.get_config_value(['--libs'], 'link_args')
self.version = self.get_pcap_lib_version()
if self.version is None:
# older pcap-config versions don't support this
self.version = self.get_pcap_lib_version()
def get_pcap_lib_version(self) -> T.Optional[str]:
# Since we seem to need to run a program to discover the pcap version,

Loading…
Cancel
Save