Skip to content

Commit 043327e

Browse files
ojedafbq
authored andcommitted
kbuild: rust_is_available: print docs reference
People trying out the Rust support in the kernel may get warnings and errors from `scripts/rust_is_available.sh` from the `rustavailable` target or the build step. Some of those users may be following the Quick Start guide, but others may not (likely those getting warnings from the build step instead of the target). While the messages are fairly clear on what the problem is, it may not be clear how to solve the particular issue, especially for those not aware of the documentation. We could add all sorts of details on the script for each one, but it is better to point users to the documentation instead, where it is easily readable in different formats. It also avoids duplication. Thus add a reference to the documentation whenever the script fails or there is at least a warning. Reviewed-by: Finn Behrens <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]> Reviewed-by: Masahiro Yamada <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e54b4ba commit 043327e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

scripts/rust_is_available.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ get_canonical_version()
1919
echo $((100000 * $1 + 100 * $2 + $3))
2020
}
2121

22+
# Print a reference to the Quick Start guide in the documentation.
23+
print_docs_reference()
24+
{
25+
echo >&2 "***"
26+
echo >&2 "*** Please see Documentation/rust/quick-start.rst for details"
27+
echo >&2 "*** on how to set up the Rust support."
28+
echo >&2 "***"
29+
}
30+
31+
# If the script fails for any reason, or if there was any warning, then
32+
# print a reference to the documentation on exit.
33+
warning=0
34+
trap 'if [ $? -ne 0 ] || [ $warning -ne 0 ]; then print_docs_reference; fi' EXIT
35+
2236
# Check that the Rust compiler exists.
2337
if ! command -v "$RUSTC" >/dev/null; then
2438
echo >&2 "***"
@@ -60,6 +74,7 @@ if [ "$rust_compiler_cversion" -gt "$rust_compiler_min_cversion" ]; then
6074
echo >&2 "*** Your version: $rust_compiler_version"
6175
echo >&2 "*** Expected version: $rust_compiler_min_version"
6276
echo >&2 "***"
77+
warning=1
6378
fi
6479

6580
# Check that the Rust bindings generator is suitable.
@@ -87,6 +102,7 @@ if [ "$rust_bindings_generator_cversion" -gt "$rust_bindings_generator_min_cvers
87102
echo >&2 "*** Your version: $rust_bindings_generator_version"
88103
echo >&2 "*** Expected version: $rust_bindings_generator_min_version"
89104
echo >&2 "***"
105+
warning=1
90106
fi
91107

92108
# Check that the `libclang` used by the Rust bindings generator is suitable.
@@ -126,6 +142,7 @@ if [ "$cc_name" = Clang ]; then
126142
echo >&2 "*** libclang version: $bindgen_libclang_version"
127143
echo >&2 "*** Clang version: $clang_version"
128144
echo >&2 "***"
145+
warning=1
129146
fi
130147
fi
131148

0 commit comments

Comments
 (0)