kbuild: rust_is_available: check that output looks as expected
authorMiguel Ojeda <ojeda@kernel.org>
Fri, 16 Jun 2023 00:16:30 +0000 (02:16 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Wed, 9 Aug 2023 23:18:34 +0000 (01:18 +0200)
commitbc60c930a43c7c984c80e99282f0d4f7193f3986
treeaeca49d58d8c4699b9541227869c514fb0d3aa0a
parentf295522886a4ebb628cadb2cd74d0661d6292978
kbuild: rust_is_available: check that output looks as expected

The script already checks for `$RUSTC` and `$BINDGEN` existing
and exiting without failure. However, one may still pass an
unexpected binary that does not output what the later parsing
expects. The script still successfully reports a failure as
expected, but the error is confusing. For instance:

    $ RUSTC=true BINDGEN=bindgen CC=clang scripts/rust_is_available.sh
    scripts/rust_is_available.sh: 19: arithmetic expression: expecting primary: "100000 *  + 100 *  + "
    ***
    *** Please see Documentation/rust/quick-start.rst for details
    *** on how to set up the Rust support.
    ***

Thus add an explicit check and a proper message for unexpected
output from the called command.

Similarly, do so for the `libclang` version parsing, too.

Link: https://lore.kernel.org/rust-for-linux/CAK7LNAQYk6s11MASRHW6oxtkqF00EJVqhHOP=5rynWt-QDUsXw@mail.gmail.com/
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Link: https://lore.kernel.org/r/20230616001631.463536-11-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
scripts/rust_is_available.sh