Skip to content

Commit

Permalink
rust: make bindgen invalid Rust target detection conditional on <0.71
Browse files Browse the repository at this point in the history
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 <kangie@gentoo.zip>
  • Loading branch information
Kangie committed Feb 25, 2025
1 parent 8389be0 commit 9b49f5f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mesonbuild/modules/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()) +
Expand Down

0 comments on commit 9b49f5f

Please sign in to comment.