@@ -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,64 +39,88 @@ 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 \
113+ aarch64-unknown-linux-musl \
96114arm-linux-androideabi \
97115arm-unknown-linux-gnueabi \
98116arm-unknown-linux-gnueabihf \
117+ arm-unknown-linux-musleabi \
118+ arm-unknown-linux-musleabihf \
99119armv7-linux-androideabi \
100120armv7-unknown-linux-gnueabihf \
121+ armv7-unknown-linux-musleabihf \
101122i586-unknown-linux-gnu \
123+ i586-unknown-linux-musl \
102124i686-linux-android \
103125i686-unknown-freebsd \
104126i686-unknown-linux-gnu \
@@ -107,113 +129,89 @@ powerpc-unknown-linux-gnu \
107129powerpc64-unknown-linux-gnu \
108130powerpc64le-unknown-linux-gnu \
109131s390x-unknown-linux-gnu \
132+ sparc64-unknown-linux-gnu \
133+ sparcv9-sun-solaris \
134+ wasm32-unknown-emscripten \
135+ wasm32-unknown-unknown \
136+ x86_64-linux-android \
110137x86_64-unknown-freebsd \
111138x86_64-unknown-linux-gnu \
112139x86_64-unknown-linux-musl \
113140x86_64-unknown-netbsd \
114141"
115142
116- RUST_GT_1_13_LINUX_TARGETS=" \
117- arm-unknown-linux-musleabi \
118- arm-unknown-linux-musleabihf \
119- armv7-unknown-linux-musleabihf \
120- sparc64-unknown-linux-gnu \
121- wasm32-unknown-emscripten \
122- x86_64-linux-android \
123- "
124- RUST_GT_1_19_LINUX_TARGETS=" \
125- aarch64-unknown-linux-musl \
126- sparcv9-sun-solaris \
127- wasm32-unknown-unknown \
128- "
129- RUST_GT_1_24_LINUX_TARGETS=" \
130- i586-unknown-linux-musl \
131- "
132-
133- RUST_NIGHTLY_LINUX_TARGETS=" \
143+ rust_nightly_linux_targets=" \
134144aarch64-unknown-fuchsia \
135145armv5te-unknown-linux-gnueabi \
136146armv5te-unknown-linux-musleabi \
137147i686-pc-windows-gnu \
138148riscv64gc-unknown-linux-gnu \
139149x86_64-fortanix-unknown-sgx \
140- x86_64-unknown-fuchsia \
141150x86_64-pc-solaris \
142151x86_64-pc-windows-gnu \
152+ x86_64-unknown-fuchsia \
143153x86_64-unknown-illumos \
144154x86_64-unknown-linux-gnux32 \
145155x86_64-unknown-redox \
146156"
147157
148- RUST_APPLE_TARGETS=" \
158+ rust_apple_targets=" \
159+ aarch64-apple-darwin \
149160aarch64-apple-ios \
150161x86_64-apple-darwin \
151162x86_64-apple-ios \
152163"
153164
154- RUST_NIGHTLY_APPLE_TARGETS=" \
155- aarch64-apple-darwin \
165+ rust_nightly_apple_targets=" \
156166"
157167
158168# Must start with `x86_64-pc-windows-msvc` first.
159- RUST_NIGHTLY_WINDOWS_TARGETS =" \
169+ rust_nightly_windows_targets =" \
160170x86_64-pc-windows-msvc \
161171x86_64-pc-windows-gnu \
162172i686-pc-windows-msvc \
163173"
164174
165175# The targets are listed here alphabetically
166- TARGETS =" "
176+ targets =" "
167177case " ${OS} " in
168178 linux* )
169- TARGETS=" ${RUST_LINUX_TARGETS} "
170-
171- if [ " ${RUST} " != " 1.13.0" ]; then
172- TARGETS=" ${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS} "
173- if [ " ${RUST} " != " 1.19.0" ]; then
174- TARGETS=" ${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS} "
175- if [ " ${RUST} " != " 1.24.0" ]; then
176- TARGETS=" ${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS} "
177- fi
178- fi
179- fi
179+ targets=" $rust_linux_targets "
180180
181- if [ " ${RUST} " = " nightly" ]; then
182- TARGETS =" ${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS} "
181+ if [ " $rust " = " nightly" ]; then
182+ targets =" $targets $rust_nightly_linux_targets "
183183 fi
184184
185185 ;;
186186 macos* )
187- TARGETS =" ${RUST_APPLE_TARGETS} "
187+ targets =" $rust_apple_targets "
188188
189- if [ " ${RUST} " = " nightly" ]; then
190- TARGETS =" ${TARGETS} ${RUST_NIGHTLY_APPLE_TARGETS} "
189+ if [ " $rust " = " nightly" ]; then
190+ targets =" $targets $rust_nightly_apple_targets "
191191 fi
192192
193193 ;;
194194 windows* )
195- TARGETS=${RUST_NIGHTLY_WINDOWS_TARGETS}
196-
197- ;;
198- * )
195+ targets=${rust_nightly_windows_targets}
199196 ;;
197+ * ) ;;
200198esac
201199
202- for TARGET in $TARGETS ; do
203- if echo " $TARGET " | grep -q " $FILTER " ; then
200+ for target in $targets ; do
201+ if echo " $target " | grep -q " $FILTER " ; then
204202 if [ " ${OS} " = " windows" ]; then
205- TARGET=" $TARGET " sh ./ci/install-rust.sh
206- test_target build " $TARGET "
203+ TARGET=" $target " sh ./ci/install-rust.sh
204+ test_target build " $target "
207205 else
208- test_target build " $TARGET "
206+ test_target build " $target "
209207 fi
210208 fi
211209done
212210
213211# Targets which are not available via rustup and must be built with -Zbuild-std
214212# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has
215213# duplicate symbol errors from `compiler_builtins`.
216- RUST_LINUX_NO_CORE_TARGETS =" \
214+ rust_linux_no_core_targets =" \
217215aarch64-pc-windows-msvc \
218216aarch64-unknown-freebsd \
219217aarch64-unknown-hermit \
@@ -278,24 +276,24 @@ x86_64-unknown-openbsd \
278276x86_64-wrs-vxworks \
279277"
280278
281- if [ " ${RUST } " = " nightly" ] && [ " ${OS} " = " linux" ]; then
282- for TARGET in $RUST_LINUX_NO_CORE_TARGETS ; do
283- if echo " $TARGET " | grep -q " $FILTER " ; then
284- test_target build " $TARGET " 1
279+ if [ " ${rust } " = " nightly" ] && [ " ${OS} " = " linux" ]; then
280+ for target in $rust_linux_no_core_targets ; do
281+ if echo " $target " | grep -q " $FILTER " ; then
282+ test_target build " $target " 1
285283 fi
286284 done
287285fi
288286
289- RUST_APPLE_NO_CORE_TARGETS =" \
287+ rust_apple_no_core_targets =" \
290288armv7s-apple-ios \
291289i686-apple-darwin \
292290i386-apple-ios \
293291"
294292
295- if [ " ${RUST } " = " nightly" ] && [ " ${OS} " = " macos" ]; then
296- for TARGET in $RUST_APPLE_NO_CORE_TARGETS ; do
297- if echo " $TARGET " | grep -q " $FILTER " ; then
298- test_target build " $TARGET " 1
293+ if [ " ${rust } " = " nightly" ] && [ " ${OS} " = " macos" ]; then
294+ for target in $rust_apple_no_core_targets ; do
295+ if echo " $target " | grep -q " $FILTER " ; then
296+ test_target build " $target " 1
299297 fi
300298 done
301299fi
0 commit comments