@@ -10,29 +10,27 @@ set -ex
1010: " ${TOOLCHAIN?The TOOLCHAIN environment variable must be set.} "
1111: " ${OS?The OS environment variable must be set.} "
1212
13- RUST=${TOOLCHAIN}
14- VERBOSE=-v
13+ rust=" $TOOLCHAIN "
1514
16- echo " Testing Rust ${RUST} on ${OS} "
15+ echo " Testing Rust $rust on $OS "
1716
18- if [ " ${ TOOLCHAIN} " = " nightly" ] ; then
17+ if [ " $TOOLCHAIN " = " nightly" ] ; then
1918 rustup component add rust-src
2019fi
2120
2221test_target () {
23- BUILD_CMD =" ${1} "
24- TARGET =" ${2} "
25- NO_STD =" ${3} "
22+ build_cmd =" ${1} "
23+ target =" ${2} "
24+ no_std =" ${3} "
2625
2726 # If there is a std component, fetch it:
28- if [ " ${NO_STD } " != " 1" ]; then
27+ if [ " ${no_std } " != " 1" ]; then
2928 # FIXME: rustup often fails to download some artifacts due to network
3029 # issues, so we retry this N times.
3130 N=5
3231 n=0
33- until [ $n -ge $N ]
34- do
35- if rustup target add " ${TARGET} " --toolchain " ${RUST} " ; then
32+ until [ $n -ge $N ]; do
33+ if rustup target add " $target " --toolchain " $rust " ; then
3634 break
3735 fi
3836 n=$(( n+ 1 ))
@@ -41,56 +39,75 @@ test_target() {
4139 fi
4240
4341 # Test that libc builds without any default features (no std)
44- if [ " ${NO_STD} " != " 1" ]; then
45- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --no-default-features --target " ${TARGET} "
42+ if [ " $no_std " != " 1" ]; then
43+ cargo " +$rust " " $build_cmd " --no-default-features --target " $target "
4644 else
4745 # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings.
48- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
49- -Z build-std=core,alloc " $VERBOSE " --no-default-features --target " ${TARGET} "
46+ RUSTFLAGS=" -A improper_ctypes_definitions" \
47+ cargo " +$rust " " $build_cmd " \
48+ -Z build-std=core,alloc \
49+ --no-default-features \
50+ --target " $target "
5051 fi
52+
5153 # Test that libc builds with default features (e.g. std)
5254 # if the target supports std
53- if [ " $NO_STD " != " 1" ]; then
54- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --target " ${TARGET} "
55+ if [ " $no_std " != " 1" ]; then
56+ cargo " +$rust " " $build_cmd " --target " $target "
5557 else
56- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
57- -Z build-std=core,alloc " $VERBOSE " --target " ${TARGET} "
58+ RUSTFLAGS=" -A improper_ctypes_definitions" \
59+ cargo " +$rust " " ${build_cmd} " \
60+ -Z build-std=core,alloc \
61+ --target " $target "
5862 fi
5963
6064 # Test that libc builds with the `extra_traits` feature
61- if [ " ${NO_STD} " != " 1" ]; then
62- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --no-default-features --target " ${TARGET} " \
63- --features extra_traits
65+ if [ " $no_std " != " 1" ]; then
66+ cargo " +$rust " " $build_cmd " \
67+ --no-default-features \
68+ --features extra_traits \
69+ --target " $target "
6470 else
65- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
66- -Z build-std=core,alloc " $VERBOSE " --no-default-features \
67- --target " ${TARGET} " --features extra_traits
71+ RUSTFLAGS=" -A improper_ctypes_definitions" \
72+ cargo " +$rust " " $build_cmd " \
73+ -Z build-std=core,alloc \
74+ --no-default-features \
75+ --features extra_traits \
76+ --target " $target "
6877 fi
6978
7079 # Test the 'const-extern-fn' feature on nightly
71- if [ " ${RUST} " = " nightly" ]; then
72- if [ " ${NO_STD} " != " 1" ]; then
73- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --no-default-features --target " ${TARGET} " \
74- --features const-extern-fn
80+ if [ " ${rust} " = " nightly" ]; then
81+ if [ " ${no_std} " != " 1" ]; then
82+ cargo " +$rust " " $build_cmd " \
83+ --no-default-features \
84+ --features const-extern-fn \
85+ --target " $target "
7586 else
76- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
77- -Z build-std=core,alloc " $VERBOSE " --no-default-features \
78- --target " ${TARGET} " --features const-extern-fn
87+ RUSTFLAGS=" -A improper_ctypes_definitions" \
88+ cargo " +$rust " " $build_cmd " \
89+ -Z build-std=core,alloc \
90+ --no-default-features \
91+ --features const-extern-fn \
92+ --target " $target "
7993 fi
8094 fi
8195
8296 # Also test that it builds with `extra_traits` and default features:
83- if [ " $NO_STD " != " 1" ]; then
84- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --target " ${TARGET} " \
97+ if [ " $no_std " != " 1" ]; then
98+ cargo " +$rust " " $build_cmd " \
99+ --target " $target " \
85100 --features extra_traits
86101 else
87- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
88- -Z build-std=core,alloc " $VERBOSE " --target " ${TARGET} " \
102+ RUSTFLAGS=" -A improper_ctypes_definitions" \
103+ cargo " +$rust " " $build_cmd " \
104+ -Z build-std=core,alloc \
105+ --target " $target " \
89106 --features extra_traits
90107 fi
91108}
92109
93- RUST_LINUX_TARGETS =" \
110+ rust_linux_targets =" \
94111aarch64-linux-android \
95112aarch64-unknown-linux-gnu \
96113arm-linux-androideabi \
@@ -113,24 +130,24 @@ x86_64-unknown-linux-musl \
113130x86_64-unknown-netbsd \
114131"
115132
116- RUST_GT_1_13_LINUX_TARGETS =" \
133+ rust_gt_1_13_linux_targets =" \
117134arm-unknown-linux-musleabi \
118135arm-unknown-linux-musleabihf \
119136armv7-unknown-linux-musleabihf \
120137sparc64-unknown-linux-gnu \
121138wasm32-unknown-emscripten \
122139x86_64-linux-android \
123140"
124- RUST_GT_1_19_LINUX_TARGETS =" \
141+ rust_gt_1_19_linux_targets =" \
125142aarch64-unknown-linux-musl \
126143sparcv9-sun-solaris \
127144wasm32-unknown-unknown \
128145"
129- RUST_GT_1_24_LINUX_TARGETS =" \
146+ rust_gt_1_24_linux_targets =" \
130147i586-unknown-linux-musl \
131148"
132149
133- RUST_NIGHTLY_LINUX_TARGETS =" \
150+ rust_nightly_linux_targets =" \
134151aarch64-unknown-fuchsia \
135152armv5te-unknown-linux-gnueabi \
136153armv5te-unknown-linux-musleabi \
@@ -145,73 +162,71 @@ x86_64-unknown-linux-gnux32 \
145162x86_64-unknown-redox \
146163"
147164
148- RUST_APPLE_TARGETS =" \
165+ rust_apple_targets =" \
149166aarch64-apple-ios \
150167"
151168
152- RUST_NIGHTLY_APPLE_TARGETS =" \
169+ rust_nightly_apple_targets =" \
153170aarch64-apple-darwin \
154171"
155172
156173# Must start with `x86_64-pc-windows-msvc` first.
157- RUST_NIGHTLY_WINDOWS_TARGETS =" \
174+ rust_nightly_windows_targets =" \
158175x86_64-pc-windows-msvc \
159176x86_64-pc-windows-gnu \
160177i686-pc-windows-msvc \
161178"
162179
163180# The targets are listed here alphabetically
164- TARGETS =" "
181+ targets =" "
165182case " ${OS} " in
166183 linux* )
167- TARGETS =" ${RUST_LINUX_TARGETS} "
184+ targets =" $rust_linux_targets "
168185
169- if [ " ${RUST} " != " 1.13.0" ]; then
170- TARGETS =" ${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS} "
171- if [ " ${RUST} " != " 1.19.0" ]; then
172- TARGETS =" ${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS} "
173- if [ " ${RUST } " != " 1.24.0" ]; then
174- TARGETS =" ${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS} "
186+ if [ " $rust " != " 1.13.0" ]; then
187+ targets =" $targets $rust_gt_1_13_linux_targets "
188+ if [ " $rust " != " 1.19.0" ]; then
189+ targets =" $targets $rust_gt_1_19_linux_targets "
190+ if [ " ${rust } " != " 1.24.0" ]; then
191+ targets =" $targets $rust_gt_1_24_linux_targets "
175192 fi
176193 fi
177194 fi
178195
179- if [ " ${RUST} " = " nightly" ]; then
180- TARGETS =" ${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS} "
196+ if [ " $rust " = " nightly" ]; then
197+ targets =" $targets $rust_nightly_linux_targets "
181198 fi
182199
183200 ;;
184201 macos* )
185- TARGETS =" ${RUST_APPLE_TARGETS} "
202+ targets =" $rust_apple_targets "
186203
187- if [ " ${RUST} " = " nightly" ]; then
188- TARGETS =" ${TARGETS} ${RUST_NIGHTLY_APPLE_TARGETS} "
204+ if [ " $rust " = " nightly" ]; then
205+ targets =" $targets $rust_nightly_apple_targets "
189206 fi
190207
191208 ;;
192209 windows* )
193- TARGETS=${RUST_NIGHTLY_WINDOWS_TARGETS}
194-
195- ;;
196- * )
210+ targets=${rust_nightly_windows_targets}
197211 ;;
212+ * ) ;;
198213esac
199214
200- for TARGET in $TARGETS ; do
201- if echo " $TARGET " | grep -q " $FILTER " ; then
215+ for target in $targets ; do
216+ if echo " $target " | grep -q " $FILTER " ; then
202217 if [ " ${OS} " = " windows" ]; then
203- TARGET=" $TARGET " sh ./ci/install-rust.sh
204- test_target build " $TARGET "
218+ TARGET=" $target " sh ./ci/install-rust.sh
219+ test_target build " $target "
205220 else
206- test_target build " $TARGET "
221+ test_target build " $target "
207222 fi
208223 fi
209224done
210225
211226# Targets which are not available via rustup and must be built with -Zbuild-std
212227# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has
213228# duplicate symbol errors from `compiler_builtins`.
214- RUST_LINUX_NO_CORE_TARGETS =" \
229+ rust_linux_no_core_targets =" \
215230aarch64-pc-windows-msvc \
216231aarch64-unknown-freebsd \
217232aarch64-unknown-hermit \
@@ -275,24 +290,24 @@ x86_64-unknown-openbsd \
275290x86_64-wrs-vxworks \
276291"
277292
278- if [ " ${RUST } " = " nightly" ] && [ " ${OS} " = " linux" ]; then
279- for TARGET in $RUST_LINUX_NO_CORE_TARGETS ; do
280- if echo " $TARGET " | grep -q " $FILTER " ; then
281- test_target build " $TARGET " 1
293+ if [ " ${rust } " = " nightly" ] && [ " ${OS} " = " linux" ]; then
294+ for target in $rust_linux_no_core_targets ; do
295+ if echo " $target " | grep -q " $FILTER " ; then
296+ test_target build " $target " 1
282297 fi
283298 done
284299fi
285300
286- RUST_APPLE_NO_CORE_TARGETS =" \
301+ rust_apple_no_core_targets =" \
287302armv7s-apple-ios \
288303i686-apple-darwin \
289304i386-apple-ios \
290305"
291306
292- if [ " ${RUST } " = " nightly" ] && [ " ${OS} " = " macos" ]; then
293- for TARGET in $RUST_APPLE_NO_CORE_TARGETS ; do
294- if echo " $TARGET " | grep -q " $FILTER " ; then
295- test_target build " $TARGET " 1
307+ if [ " ${rust } " = " nightly" ] && [ " ${OS} " = " macos" ]; then
308+ for target in $rust_apple_no_core_targets ; do
309+ if echo " $target " | grep -q " $FILTER " ; then
310+ test_target build " $target " 1
296311 fi
297312 done
298313fi
0 commit comments