@@ -10,29 +10,28 @@ 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
3332 until [ $n -ge $N ]
3433 do
35- if rustup target add " ${TARGET} " --toolchain " ${RUST} " ; then
34+ if rustup target add " $target " --toolchain " $rust " ; then
3635 break
3736 fi
3837 n=$(( n+ 1 ))
@@ -41,56 +40,75 @@ test_target() {
4140 fi
4241
4342 # 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} "
43+ if [ " $no_std " != " 1" ]; then
44+ cargo " +$rust " " $build_cmd " --no-default-features --target " $target "
4645 else
4746 # 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} "
47+ RUSTFLAGS=" -A improper_ctypes_definitions" \
48+ cargo " +$rust " " $build_cmd " \
49+ -Z build-std=core,alloc \
50+ --no-default-features \
51+ --target " $target "
5052 fi
53+
5154 # Test that libc builds with default features (e.g. std)
5255 # if the target supports std
53- if [ " $NO_STD " != " 1" ]; then
54- cargo " +${RUST} " " ${BUILD_CMD} " " $VERBOSE " --target " ${TARGET} "
56+ if [ " $no_std " != " 1" ]; then
57+ cargo " +$rust " " $build_cmd " --target " $target "
5558 else
56- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
57- -Z build-std=core,alloc " $VERBOSE " --target " ${TARGET} "
59+ RUSTFLAGS=" -A improper_ctypes_definitions" \
60+ cargo " +$rust " " ${build_cmd} " \
61+ -Z build-std=core,alloc \
62+ --target " $target "
5863 fi
5964
6065 # 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
66+ if [ " $no_std " != " 1" ]; then
67+ cargo " +$rust " " $build_cmd " \
68+ --no-default-features \
69+ --features extra_traits \
70+ --target " $target "
6471 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
72+ RUSTFLAGS=" -A improper_ctypes_definitions" \
73+ cargo " +$rust " " $build_cmd " \
74+ -Z build-std=core,alloc \
75+ --no-default-features \
76+ --features extra_traits \
77+ --target " $target "
6878 fi
6979
7080 # 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
81+ if [ " ${rust} " = " nightly" ]; then
82+ if [ " ${no_std} " != " 1" ]; then
83+ cargo " +$rust " " $build_cmd " \
84+ --no-default-features \
85+ --features const-extern-fn \
86+ --target " $target "
7587 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
88+ RUSTFLAGS=" -A improper_ctypes_definitions" \
89+ cargo " +$rust " " $build_cmd " \
90+ -Z build-std=core,alloc \
91+ --no-default-features \
92+ --features const-extern-fn \
93+ --target " $target "
7994 fi
8095 fi
8196
8297 # 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} " \
98+ if [ " $no_std " != " 1" ]; then
99+ cargo " +$rust " " $build_cmd " \
100+ --target " $target " \
85101 --features extra_traits
86102 else
87- RUSTFLAGS=" -A improper_ctypes_definitions" cargo " +${RUST} " " ${BUILD_CMD} " \
88- -Z build-std=core,alloc " $VERBOSE " --target " ${TARGET} " \
103+ RUSTFLAGS=" -A improper_ctypes_definitions" \
104+ cargo " +$rust " " $build_cmd " \
105+ -Z build-std=core,alloc \
106+ --target " $target " \
89107 --features extra_traits
90108 fi
91109}
92110
93- RUST_LINUX_TARGETS =" \
111+ rust_linux_targets =" \
94112aarch64-linux-android \
95113aarch64-unknown-linux-gnu \
96114arm-linux-androideabi \
@@ -113,24 +131,24 @@ x86_64-unknown-linux-musl \
113131x86_64-unknown-netbsd \
114132"
115133
116- RUST_GT_1_13_LINUX_TARGETS =" \
134+ rust_gt_1_13_linux_targets =" \
117135arm-unknown-linux-musleabi \
118136arm-unknown-linux-musleabihf \
119137armv7-unknown-linux-musleabihf \
120138sparc64-unknown-linux-gnu \
121139wasm32-unknown-emscripten \
122140x86_64-linux-android \
123141"
124- RUST_GT_1_19_LINUX_TARGETS =" \
142+ rust_gt_1_19_linux_targets =" \
125143aarch64-unknown-linux-musl \
126144sparcv9-sun-solaris \
127145wasm32-unknown-unknown \
128146"
129- RUST_GT_1_24_LINUX_TARGETS =" \
147+ rust_gt_1_24_linux_targets =" \
130148i586-unknown-linux-musl \
131149"
132150
133- RUST_NIGHTLY_LINUX_TARGETS =" \
151+ rust_nightly_linux_targets =" \
134152aarch64-unknown-fuchsia \
135153armv5te-unknown-linux-gnueabi \
136154armv5te-unknown-linux-musleabi \
@@ -145,73 +163,71 @@ x86_64-unknown-linux-gnux32 \
145163x86_64-unknown-redox \
146164"
147165
148- RUST_APPLE_TARGETS =" \
166+ rust_apple_targets =" \
149167aarch64-apple-ios \
150168"
151169
152- RUST_NIGHTLY_APPLE_TARGETS =" \
170+ rust_nightly_apple_targets =" \
153171aarch64-apple-darwin \
154172"
155173
156174# Must start with `x86_64-pc-windows-msvc` first.
157- RUST_NIGHTLY_WINDOWS_TARGETS =" \
175+ rust_nightly_windows_targets =" \
158176x86_64-pc-windows-msvc \
159177x86_64-pc-windows-gnu \
160178i686-pc-windows-msvc \
161179"
162180
163181# The targets are listed here alphabetically
164- TARGETS =" "
182+ targets =" "
165183case " ${OS} " in
166184 linux* )
167- TARGETS =" ${RUST_LINUX_TARGETS} "
185+ targets =" $rust_linux_targets "
168186
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} "
187+ if [ " $rust " != " 1.13.0" ]; then
188+ targets =" $targets $rust_gt_1_13_linux_targets "
189+ if [ " $rust " != " 1.19.0" ]; then
190+ targets =" $targets $rust_gt_1_19_linux_targets "
191+ if [ " ${rust } " != " 1.24.0" ]; then
192+ targets =" $targets $rust_gt_1_24_linux_targets "
175193 fi
176194 fi
177195 fi
178196
179- if [ " ${RUST} " = " nightly" ]; then
180- TARGETS =" ${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS} "
197+ if [ " $rust " = " nightly" ]; then
198+ targets =" $targets $rust_nightly_linux_targets "
181199 fi
182200
183201 ;;
184202 macos* )
185- TARGETS =" ${RUST_APPLE_TARGETS} "
203+ targets =" $rust_apple_targets "
186204
187- if [ " ${RUST} " = " nightly" ]; then
188- TARGETS =" ${TARGETS} ${RUST_NIGHTLY_APPLE_TARGETS} "
205+ if [ " $rust " = " nightly" ]; then
206+ targets =" $targets $rust_nightly_apple_targets "
189207 fi
190208
191209 ;;
192210 windows* )
193- TARGETS=${RUST_NIGHTLY_WINDOWS_TARGETS}
194-
195- ;;
196- * )
211+ targets=${rust_nightly_windows_targets}
197212 ;;
213+ * ) ;;
198214esac
199215
200- for TARGET in $TARGETS ; do
201- if echo " $TARGET " | grep -q " $FILTER " ; then
216+ for target in $targets ; do
217+ if echo " $target " | grep -q " $FILTER " ; then
202218 if [ " ${OS} " = " windows" ]; then
203- TARGET =" $TARGET " sh ./ci/install-rust.sh
204- test_target build " $TARGET "
219+ target =" $target " sh ./ci/install-rust.sh
220+ test_target build " $target "
205221 else
206- test_target build " $TARGET "
222+ test_target build " $target "
207223 fi
208224 fi
209225done
210226
211227# Targets which are not available via rustup and must be built with -Zbuild-std
212228# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has
213229# duplicate symbol errors from `compiler_builtins`.
214- RUST_LINUX_NO_CORE_TARGETS =" \
230+ rust_linux_no_core_targets =" \
215231aarch64-pc-windows-msvc \
216232aarch64-unknown-freebsd \
217233aarch64-unknown-hermit \
@@ -275,24 +291,24 @@ x86_64-unknown-openbsd \
275291x86_64-wrs-vxworks \
276292"
277293
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
294+ if [ " ${rust } " = " nightly" ] && [ " ${OS} " = " linux" ]; then
295+ for target in $rust_linux_no_core_targets ; do
296+ if echo " $target " | grep -q " $FILTER " ; then
297+ test_target build " $target " 1
282298 fi
283299 done
284300fi
285301
286- RUST_APPLE_NO_CORE_TARGETS =" \
302+ rust_apple_no_core_targets =" \
287303armv7s-apple-ios \
288304i686-apple-darwin \
289305i386-apple-ios \
290306"
291307
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
308+ if [ " ${rust } " = " nightly" ] && [ " ${OS} " = " macos" ]; then
309+ for target in $rust_apple_no_core_targets ; do
310+ if echo " $target " | grep -q " $FILTER " ; then
311+ test_target build " $target " 1
296312 fi
297313 done
298314fi
0 commit comments