diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-01-10 02:06:16 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-01-18 18:06:08 -0500 |
commit | 921ddb1980e1a8d08f8706a1556896793dafccbe (patch) | |
tree | d5d030e14a32286dbfe9af48e5b50fc19befd762 | |
parent | c49552ffb2cbcd4a9d9873732c6f260ba5fc1b50 (diff) | |
download | meson-921ddb1980e1a8d08f8706a1556896793dafccbe.zip meson-921ddb1980e1a8d08f8706a1556896793dafccbe.tar.gz meson-921ddb1980e1a8d08f8706a1556896793dafccbe.tar.bz2 |
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.
-rw-r--r-- | mesonbuild/dependencies/configtool.py | 12 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 8 |
2 files changed, 18 insertions, 2 deletions
diff --git a/mesonbuild/dependencies/configtool.py b/mesonbuild/dependencies/configtool.py index 8b7f1bb..1c8d730 100644 --- a/mesonbuild/dependencies/configtool.py +++ b/mesonbuild/dependencies/configtool.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 diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index d23eeee..07f4e9a 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -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, |