From 9b49f5ff7614320df55c2d0b5720e5df374744d6 Mon Sep 17 00:00:00 2001 From: Matt Jolly Date: Tue, 25 Feb 2025 14:18:53 +1000 Subject: [PATCH] rust: make bindgen invalid Rust target detection conditional on <0.71 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 0.71.0 the bindgen output for invalid rust targets was changed to "«version» is not a valid Rust target". This breaks the existing detection. Further investigation revealed that from 0.71.0 we probably don't need to do this check; "all*" Rust versions will be accepted as valid and converted internally to an appropriate target. Bindgen does not like `-beta` or `-nightly` suffixes, we'll have to address that separately depending on the outcome of rust-lang/rust-bindgen#3152. See-also: rust-lang/rust-bindgen#2993 Signed-off-by: Matt Jolly --- mesonbuild/modules/rust.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index 3638964f28ef..04ba6a514ed2 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -254,7 +254,13 @@ def bindgen(self, state: ModuleState, args: T.List, kwargs: FuncBindgen) -> Modu if self._bindgen_bin is None: self._bindgen_bin = state.find_program('bindgen', wanted=kwargs['bindgen_version']) - if self._bindgen_rust_target is not None: + self._bindgen_bin_version = self._bindgen_bin.get_version() + # bindgen 0.71 enables more flexible target specification, any* Rust version string + # will be accepted as valid and will be automatically converted to an appropriate target + # based on internal logic. See rust-lang/rust-bindgen#2993 for more information. + # Additionally the 'invalid Rust target' output is changed in bindgen 0.71 and will not + # match the conditional below. + if self._bindgen_rust_target is not None and self._bindgen_bin_version < '0.71': # ExternalCommand.command's type is bonkers _, _, err = mesonlib.Popen_safe( T.cast('T.List[str]', self._bindgen_bin.get_command()) +