Skip to content

Commit 9b49f5f

Browse files
committed
rust: make bindgen invalid Rust target detection conditional on <0.71
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 <[email protected]>
1 parent 8389be0 commit 9b49f5f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mesonbuild/modules/rust.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,13 @@ def bindgen(self, state: ModuleState, args: T.List, kwargs: FuncBindgen) -> Modu
254254

255255
if self._bindgen_bin is None:
256256
self._bindgen_bin = state.find_program('bindgen', wanted=kwargs['bindgen_version'])
257-
if self._bindgen_rust_target is not None:
257+
self._bindgen_bin_version = self._bindgen_bin.get_version()
258+
# bindgen 0.71 enables more flexible target specification, any* Rust version string
259+
# will be accepted as valid and will be automatically converted to an appropriate target
260+
# based on internal logic. See rust-lang/rust-bindgen#2993 for more information.
261+
# Additionally the 'invalid Rust target' output is changed in bindgen 0.71 and will not
262+
# match the conditional below.
263+
if self._bindgen_rust_target is not None and self._bindgen_bin_version < '0.71':
258264
# ExternalCommand.command's type is bonkers
259265
_, _, err = mesonlib.Popen_safe(
260266
T.cast('T.List[str]', self._bindgen_bin.get_command()) +

0 commit comments

Comments
 (0)