Skip to content

Commit f88b5e0

Browse files
committed
ci: make scripts more uniform
Perform the following style changes: - Only use uppercase variable names if they are exported - Only use `${...}` syntax when joining with other strings, `$...` otherwise - Use `CARGO_TERM_VERBOSE` rather than always passing `-v` - Indent is always four spaces
1 parent 3a0b044 commit f88b5e0

File tree

10 files changed

+172
-156
lines changed

10 files changed

+172
-156
lines changed

.github/workflows/full_ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
types: [opened, synchronize, reopened]
77

88
env:
9+
CARGO_TERM_VERBOSE: 1
910
LIBC_CI: 1
1011

1112
jobs:

ci/android-install-ndk.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
set -ex
44

5-
NDK=android-ndk-r27
6-
wget --tries=20 -q https://dl.google.com/android/repository/${NDK}-linux.zip
7-
unzip -q ${NDK}-linux.zip
5+
ndk=android-ndk-r27
6+
wget --tries=20 -q "https://dl.google.com/android/repository/${ndk}-linux.zip"
7+
unzip -q "${ndk}-linux.zip"
88

9-
mv ./${NDK}/toolchains/llvm/prebuilt/linux-x86_64 /android
9+
mv "./${ndk}/toolchains/llvm/prebuilt/linux-x86_64" /android
1010

11-
rm -rf ./${NDK}-linux.zip ./${NDK}
11+
rm -rf "./${ndk}-linux.zip" "./${ndk}"

ci/android-install-sdk.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
set -ex
44

5-
# Prep the SDK and emulator
5+
# Prep the sdk and emulator
66
#
77
# Note that the update process requires that we accept a bunch of licenses, and
88
# we can't just pipe `yes` into it for some reason, so we take the same strategy
99
# located in https://github.com/appunite/docker by just wrapping it in a script
1010
# which apparently magically accepts the licenses.
1111

12-
SDK=6609375
12+
sdk=6609375
1313
mkdir -p sdk/cmdline-tools
14-
wget -q --tries=20 https://dl.google.com/android/repository/commandlinetools-linux-${SDK}_latest.zip
15-
unzip -q -d sdk/cmdline-tools commandlinetools-linux-${SDK}_latest.zip
14+
wget -q --tries=20 "https://dl.google.com/android/repository/commandlinetools-linux-${sdk}_latest.zip"
15+
unzip -q -d sdk/cmdline-tools "commandlinetools-linux-${sdk}_latest.zip"
1616

1717
case "$1" in
1818
arm | armv7)
@@ -69,4 +69,4 @@ echo "no" |
6969
--name "${1}" \
7070
--package "${image}" | grep -v = || true
7171

72-
rm -rf commandlinetools-linux-${SDK}_latest.zip emulator-linux_x64-9058569.zip
72+
rm -rf "commandlinetools-linux-${sdk}_latest.zip" emulator-linux_x64-9058569.zip

ci/build.sh

Lines changed: 90 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -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
2019
fi
2120

2221
test_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="\
94112
aarch64-linux-android \
95113
aarch64-unknown-linux-gnu \
96114
arm-linux-androideabi \
@@ -113,24 +131,24 @@ x86_64-unknown-linux-musl \
113131
x86_64-unknown-netbsd \
114132
"
115133

116-
RUST_GT_1_13_LINUX_TARGETS="\
134+
rust_gt_1_13_linux_targets="\
117135
arm-unknown-linux-musleabi \
118136
arm-unknown-linux-musleabihf \
119137
armv7-unknown-linux-musleabihf \
120138
sparc64-unknown-linux-gnu \
121139
wasm32-unknown-emscripten \
122140
x86_64-linux-android \
123141
"
124-
RUST_GT_1_19_LINUX_TARGETS="\
142+
rust_gt_1_19_linux_targets="\
125143
aarch64-unknown-linux-musl \
126144
sparcv9-sun-solaris \
127145
wasm32-unknown-unknown \
128146
"
129-
RUST_GT_1_24_LINUX_TARGETS="\
147+
rust_gt_1_24_linux_targets="\
130148
i586-unknown-linux-musl \
131149
"
132150

133-
RUST_NIGHTLY_LINUX_TARGETS="\
151+
rust_nightly_linux_targets="\
134152
aarch64-unknown-fuchsia \
135153
armv5te-unknown-linux-gnueabi \
136154
armv5te-unknown-linux-musleabi \
@@ -145,73 +163,71 @@ x86_64-unknown-linux-gnux32 \
145163
x86_64-unknown-redox \
146164
"
147165

148-
RUST_APPLE_TARGETS="\
166+
rust_apple_targets="\
149167
aarch64-apple-ios \
150168
"
151169

152-
RUST_NIGHTLY_APPLE_TARGETS="\
170+
rust_nightly_apple_targets="\
153171
aarch64-apple-darwin \
154172
"
155173

156174
# Must start with `x86_64-pc-windows-msvc` first.
157-
RUST_NIGHTLY_WINDOWS_TARGETS="\
175+
rust_nightly_windows_targets="\
158176
x86_64-pc-windows-msvc \
159177
x86_64-pc-windows-gnu \
160178
i686-pc-windows-msvc \
161179
"
162180

163181
# The targets are listed here alphabetically
164-
TARGETS=""
182+
targets=""
165183
case "${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+
*) ;;
198214
esac
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
209225
done
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="\
215231
aarch64-pc-windows-msvc \
216232
aarch64-unknown-freebsd \
217233
aarch64-unknown-hermit \
@@ -275,24 +291,24 @@ x86_64-unknown-openbsd \
275291
x86_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
284300
fi
285301

286-
RUST_APPLE_NO_CORE_TARGETS="\
302+
rust_apple_no_core_targets="\
287303
armv7s-apple-ios \
288304
i686-apple-darwin \
289305
i386-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
298314
fi

ci/docker/wasm32-unknown-emscripten/node-wrapper.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
set -e
44

5-
me=$1
5+
me="$1"
66
shift
7-
dir=$(dirname $me)
8-
file=$(basename $me)
7+
dir=$(dirname "$me")
8+
file=$(basename "$me")
99

10-
cd $dir
11-
exec node $file "$@"
10+
cd "$dir"
11+
exec node "$file" "$@"

ci/emscripten.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ set -ex
44

55
# Note: keep in sync with:
66
# https://github.com/rust-lang/rust/blob/master/src/ci/docker/scripts/emscripten.sh
7-
EMSDK_VERSION=3.1.68
7+
emsdk_version=3.1.68
88

99
git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
1010
cd /emsdk-portable
11-
./emsdk install "${EMSDK_VERSION}"
12-
./emsdk activate "${EMSDK_VERSION}"
11+
./emsdk install "$emsdk_version"
12+
./emsdk activate "$emsdk_version"
1313

1414
# Compile and cache libc
1515
# shellcheck disable=SC1091

0 commit comments

Comments
 (0)