modules/rust: Update bindgen target error checking for bindgen >= 0.71

Which has both changed the error message and relaxed the check. In
theory we wouldn't hit this unless you have a very old bindgen and a
very new rustc.
This commit is contained in:
Dylan Baker 2025-02-26 09:23:12 -08:00 committed by Eli Schwartz
parent de7d8f9e48
commit 95dd7499f3
1 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2020-2024 Intel Corporation
# Copyright © 2020-2025 Intel Corporation
from __future__ import annotations
import itertools
@ -259,9 +259,11 @@ class RustModule(ExtensionModule):
_, _, err = mesonlib.Popen_safe(
T.cast('T.List[str]', self._bindgen_bin.get_command()) +
['--rust-target', self._bindgen_rust_target])
# Sometimes this is "invalid Rust target" and sometimes "invalid
# rust target"
if 'Got an invalid' in err:
# < 0.71: Sometimes this is "invalid Rust target" and
# sometimes "invalid # rust target"
# >= 0.71: error: invalid value '...' for '--rust-target <RUST_TARGET>': "..." is not a valid Rust target, accepted values are of the form ...
# It's also much harder to hit this in 0.71 than in previous versions
if 'Got an invalid' in err or 'is not a valid Rust target' in err:
self._bindgen_rust_target = None
name: str