Skip to content

Commit d824d2f

Browse files
masahir0yojeda
authored andcommitted
kbuild: rust_is_available: remove -v option
The -v option is passed when this script is invoked from Makefile, but not when invoked from Kconfig. As you can see in scripts/Kconfig.include, the 'success' macro suppresses stdout and stderr anyway, so this script does not need to be quiet. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Miguel Ojeda <[email protected]> Tested-by: Miguel Ojeda <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded prefix to match the others in the patch series. ] Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent d4d84ea commit d824d2f

File tree

2 files changed

+42
-58
lines changed

2 files changed

+42
-58
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ prepare0: archprepare
12891289
# All the preparing..
12901290
prepare: prepare0
12911291
ifdef CONFIG_RUST
1292-
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh -v
1292+
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh
12931293
$(Q)$(MAKE) $(build)=rust
12941294
endif
12951295

@@ -1825,7 +1825,7 @@ $(DOC_TARGETS):
18251825
# "Is Rust available?" target
18261826
PHONY += rustavailable
18271827
rustavailable:
1828-
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh -v && echo "Rust is available!"
1828+
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh && echo "Rust is available!"
18291829

18301830
# Documentation target
18311831
#

scripts/rust_is_available.sh

Lines changed: 40 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# SPDX-License-Identifier: GPL-2.0
33
#
44
# Tests whether a suitable Rust toolchain is available.
5-
#
6-
# Pass `-v` for human output and more checks (as warnings).
75

86
set -e
97

@@ -23,21 +21,17 @@ get_canonical_version()
2321

2422
# Check that the Rust compiler exists.
2523
if ! command -v "$RUSTC" >/dev/null; then
26-
if [ "$1" = -v ]; then
27-
echo >&2 "***"
28-
echo >&2 "*** Rust compiler '$RUSTC' could not be found."
29-
echo >&2 "***"
30-
fi
24+
echo >&2 "***"
25+
echo >&2 "*** Rust compiler '$RUSTC' could not be found."
26+
echo >&2 "***"
3127
exit 1
3228
fi
3329

3430
# Check that the Rust bindings generator exists.
3531
if ! command -v "$BINDGEN" >/dev/null; then
36-
if [ "$1" = -v ]; then
37-
echo >&2 "***"
38-
echo >&2 "*** Rust bindings generator '$BINDGEN' could not be found."
39-
echo >&2 "***"
40-
fi
32+
echo >&2 "***"
33+
echo >&2 "*** Rust bindings generator '$BINDGEN' could not be found."
34+
echo >&2 "***"
4135
exit 1
4236
fi
4337

@@ -53,16 +47,14 @@ rust_compiler_min_version=$($min_tool_version rustc)
5347
rust_compiler_cversion=$(get_canonical_version $rust_compiler_version)
5448
rust_compiler_min_cversion=$(get_canonical_version $rust_compiler_min_version)
5549
if [ "$rust_compiler_cversion" -lt "$rust_compiler_min_cversion" ]; then
56-
if [ "$1" = -v ]; then
57-
echo >&2 "***"
58-
echo >&2 "*** Rust compiler '$RUSTC' is too old."
59-
echo >&2 "*** Your version: $rust_compiler_version"
60-
echo >&2 "*** Minimum version: $rust_compiler_min_version"
61-
echo >&2 "***"
62-
fi
50+
echo >&2 "***"
51+
echo >&2 "*** Rust compiler '$RUSTC' is too old."
52+
echo >&2 "*** Your version: $rust_compiler_version"
53+
echo >&2 "*** Minimum version: $rust_compiler_min_version"
54+
echo >&2 "***"
6355
exit 1
6456
fi
65-
if [ "$1" = -v ] && [ "$rust_compiler_cversion" -gt "$rust_compiler_min_cversion" ]; then
57+
if [ "$rust_compiler_cversion" -gt "$rust_compiler_min_cversion" ]; then
6658
echo >&2 "***"
6759
echo >&2 "*** Rust compiler '$RUSTC' is too new. This may or may not work."
6860
echo >&2 "*** Your version: $rust_compiler_version"
@@ -82,16 +74,14 @@ rust_bindings_generator_min_version=$($min_tool_version bindgen)
8274
rust_bindings_generator_cversion=$(get_canonical_version $rust_bindings_generator_version)
8375
rust_bindings_generator_min_cversion=$(get_canonical_version $rust_bindings_generator_min_version)
8476
if [ "$rust_bindings_generator_cversion" -lt "$rust_bindings_generator_min_cversion" ]; then
85-
if [ "$1" = -v ]; then
86-
echo >&2 "***"
87-
echo >&2 "*** Rust bindings generator '$BINDGEN' is too old."
88-
echo >&2 "*** Your version: $rust_bindings_generator_version"
89-
echo >&2 "*** Minimum version: $rust_bindings_generator_min_version"
90-
echo >&2 "***"
91-
fi
77+
echo >&2 "***"
78+
echo >&2 "*** Rust bindings generator '$BINDGEN' is too old."
79+
echo >&2 "*** Your version: $rust_bindings_generator_version"
80+
echo >&2 "*** Minimum version: $rust_bindings_generator_min_version"
81+
echo >&2 "***"
9282
exit 1
9383
fi
94-
if [ "$1" = -v ] && [ "$rust_bindings_generator_cversion" -gt "$rust_bindings_generator_min_cversion" ]; then
84+
if [ "$rust_bindings_generator_cversion" -gt "$rust_bindings_generator_min_cversion" ]; then
9585
echo >&2 "***"
9686
echo >&2 "*** Rust bindings generator '$BINDGEN' is too new. This may or may not work."
9787
echo >&2 "*** Your version: $rust_bindings_generator_version"
@@ -110,13 +100,11 @@ bindgen_libclang_min_version=$($min_tool_version llvm)
110100
bindgen_libclang_cversion=$(get_canonical_version $bindgen_libclang_version)
111101
bindgen_libclang_min_cversion=$(get_canonical_version $bindgen_libclang_min_version)
112102
if [ "$bindgen_libclang_cversion" -lt "$bindgen_libclang_min_cversion" ]; then
113-
if [ "$1" = -v ]; then
114-
echo >&2 "***"
115-
echo >&2 "*** libclang (used by the Rust bindings generator '$BINDGEN') is too old."
116-
echo >&2 "*** Your version: $bindgen_libclang_version"
117-
echo >&2 "*** Minimum version: $bindgen_libclang_min_version"
118-
echo >&2 "***"
119-
fi
103+
echo >&2 "***"
104+
echo >&2 "*** libclang (used by the Rust bindings generator '$BINDGEN') is too old."
105+
echo >&2 "*** Your version: $bindgen_libclang_version"
106+
echo >&2 "*** Minimum version: $bindgen_libclang_min_version"
107+
echo >&2 "***"
120108
exit 1
121109
fi
122110

@@ -125,21 +113,19 @@ fi
125113
#
126114
# In the future, we might be able to perform a full version check, see
127115
# https://github.com/rust-lang/rust-bindgen/issues/2138.
128-
if [ "$1" = -v ]; then
129-
cc_name=$($(dirname $0)/cc-version.sh "$CC" | cut -f1 -d' ')
130-
if [ "$cc_name" = Clang ]; then
131-
clang_version=$( \
132-
LC_ALL=C "$CC" --version 2>/dev/null \
133-
| sed -nE '1s:.*version ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p'
134-
)
135-
if [ "$clang_version" != "$bindgen_libclang_version" ]; then
136-
echo >&2 "***"
137-
echo >&2 "*** libclang (used by the Rust bindings generator '$BINDGEN')"
138-
echo >&2 "*** version does not match Clang's. This may be a problem."
139-
echo >&2 "*** libclang version: $bindgen_libclang_version"
140-
echo >&2 "*** Clang version: $clang_version"
141-
echo >&2 "***"
142-
fi
116+
cc_name=$($(dirname $0)/cc-version.sh "$CC" | cut -f1 -d' ')
117+
if [ "$cc_name" = Clang ]; then
118+
clang_version=$( \
119+
LC_ALL=C "$CC" --version 2>/dev/null \
120+
| sed -nE '1s:.*version ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p'
121+
)
122+
if [ "$clang_version" != "$bindgen_libclang_version" ]; then
123+
echo >&2 "***"
124+
echo >&2 "*** libclang (used by the Rust bindings generator '$BINDGEN')"
125+
echo >&2 "*** version does not match Clang's. This may be a problem."
126+
echo >&2 "*** libclang version: $bindgen_libclang_version"
127+
echo >&2 "*** Clang version: $clang_version"
128+
echo >&2 "***"
143129
fi
144130
fi
145131

@@ -150,11 +136,9 @@ rustc_sysroot=$("$RUSTC" $KRUSTFLAGS --print sysroot)
150136
rustc_src=${RUST_LIB_SRC:-"$rustc_sysroot/lib/rustlib/src/rust/library"}
151137
rustc_src_core="$rustc_src/core/src/lib.rs"
152138
if [ ! -e "$rustc_src_core" ]; then
153-
if [ "$1" = -v ]; then
154-
echo >&2 "***"
155-
echo >&2 "*** Source code for the 'core' standard library could not be found"
156-
echo >&2 "*** at '$rustc_src_core'."
157-
echo >&2 "***"
158-
fi
139+
echo >&2 "***"
140+
echo >&2 "*** Source code for the 'core' standard library could not be found"
141+
echo >&2 "*** at '$rustc_src_core'."
142+
echo >&2 "***"
159143
exit 1
160144
fi

0 commit comments

Comments
 (0)