Skip to content

Commit 9e0df33

Browse files
committed
CI/CD: Restore mk/install-build-tools.sh.
1 parent 9ab293a commit 9e0df33

File tree

3 files changed

+97
-45
lines changed

3 files changed

+97
-45
lines changed

.github/workflows/ci.yml

+25-44
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
runs-on: ${{ matrix.host_os }}
1919
strategy:
2020
matrix:
21+
features:
22+
- # Default
2123
host_os:
2224
- ubuntu-18.04
2325
- macos-latest
@@ -34,13 +36,18 @@ jobs:
3436
with:
3537
override: true
3638
toolchain: ${{ matrix.rust_channel }}
39+
3740
- uses: actions/checkout@v2
38-
- run: cargo test -vv ${{ matrix.mode }}
41+
42+
- run: |
43+
cargo test -vv ${{ matrix.features }} ${{ matrix.mode }}
3944
4045
test-cross-linux-linux:
4146
runs-on: ${{ matrix.host_os }}
4247
strategy:
4348
matrix:
49+
features:
50+
- # Default
4451
host_os:
4552
- ubuntu-18.04
4653
mode:
@@ -57,38 +64,16 @@ jobs:
5764
- i686-unknown-linux-musl
5865
- x86_64-unknown-linux-musl
5966
steps:
60-
# qemu-user is needed only to run the tests, not for `cargo build` or
61-
# `cargo test --no-run`.
62-
- if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
63-
run: |
64-
sudo apt-get -yq --no-install-suggests --no-install-recommends install \
65-
gcc-aarch64-linux-gnu \
66-
libc6-dev-arm64-cross \
67-
qemu-user
68-
69-
# qemu-user is needed only to run the tests, not for `cargo build` or
70-
# `cargo test --no-run`.
71-
- if: ${{ matrix.target == 'arm-unknown-linux-gnueabihf' }}
72-
run: |
73-
sudo apt-get -yq --no-install-suggests --no-install-recommends install \
74-
gcc-arm-linux-gnueabihf \
75-
libc6-dev-armhf-cross \
76-
qemu-user
67+
- uses: actions/checkout@v2
7768

78-
# TODO: musl i686 shouldn't be using gcc-multilib or libc6-dev-i386.
79-
- if: ${{ contains(matrix.target, 'i686') }}
80-
run: |
81-
sudo apt-get -yq --no-install-suggests --no-install-recommends install \
82-
gcc-multilib \
83-
libc6-dev-i386
69+
- run: mk/install-build-tools.sh --target=${{ matrix.target }} ${{ matrix.features }}
8470

8571
- uses: actions-rs/toolchain@v1
8672
with:
8773
override: true
74+
target: ${{ matrix.target }}
8875
toolchain: ${{ matrix.rust_channel }}
8976

90-
- uses: actions/checkout@v2
91-
9277
- run: |
9378
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
9479
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
@@ -102,7 +87,7 @@ jobs:
10287
CARGO_TARGET_i686_UNKNOWN_LINUX_MUSL_LINKER=clang \
10388
CC_x86_64_unknown_linux_musl=clang \
10489
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=clang \
105-
cargo test -vv ${{ matrix.mode }}
90+
cargo test -vv --target=${{ matrix.target }} ${{ matrix.features }} ${{ matrix.mode }}
10691
10792
# Verify cross-compiling with the default feature set works.
10893
build-cross-linux:
@@ -125,20 +110,16 @@ jobs:
125110
- aarch64-linux-android
126111
- armv7-linux-androideabi
127112
steps:
128-
- if: ${{ contains(matrix.target, 'android') }}
129-
run: |
130-
mkdir -p "${ANDROID_SDK_ROOT}/licenses" && \
131-
echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "${ANDROID_SDK_ROOT}/licenses/android-sdk-license" && \
132-
sudo "${ANDROID_SDK_ROOT}/tools/bin/sdkmanager" ndk-bundle
113+
- uses: actions/checkout@v2
114+
115+
- run: mk/install-build-tools.sh --target=${{ matrix.target }} ${{ matrix.features }}
133116

134117
- uses: actions-rs/toolchain@v1
135118
with:
136119
override: true
137120
target: ${{ matrix.target }}
138121
toolchain: ${{ matrix.rust_channel }}
139122

140-
- uses: actions/checkout@v2
141-
142123
# wasm32-*: When the "wasm32_c" feature isn't enabled, we don't need to set anything.
143124
# TODO: Collect the resultant artifacts and/or run the tests.
144125
- run: |
@@ -147,15 +128,15 @@ jobs:
147128
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android21-clang \
148129
CC_armv7_linux_androideabi=armv7a-linux-androideabi18-clang \
149130
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi18-clang \
150-
cargo test --no-run -vv ${{ matrix.features }} ${{ matrix.mode }} --target=${{ matrix.target }}
131+
cargo test -vv --no-run --target=${{ matrix.target }} ${{ matrix.features }} ${{ matrix.mode }}
151132
152133
# Verify that the the "wasm32_c" configuration builds.
153134
build-cross-wasm32-c:
154135
runs-on: ${{ matrix.host_os }}
155136
strategy:
156137
matrix:
157138
features:
158-
- --features="wasm32_c"
139+
- --features=wasm32_c
159140
host_os:
160141
- ubuntu-18.04
161142
mode:
@@ -169,26 +150,24 @@ jobs:
169150
- wasm32-unknown-unknown
170151

171152
steps:
172-
# "wasm_c" has only been tested with clang-10 and llvm-ar-10. The build
173-
# will fail when using some older versions.
174-
- run: sudo apt-get -yq --no-install-suggests --no-install-recommends install clang-10 llvm-10
153+
- uses: actions/checkout@v2
154+
155+
- run: mk/install-build-tools.sh --target=${{ matrix.target }} ${{ matrix.features }}
175156

176157
- uses: actions-rs/toolchain@v1
177158
with:
178159
override: true
179160
target: ${{ matrix.target }}
180161
toolchain: ${{ matrix.rust_channel }}
181162

182-
- uses: actions/checkout@v2
183-
184163
- env:
185164
# These are only needed for for wasm32 targets only, only when the "wasm_c"
186165
# feature is enabled.
187166
CC_wasm32_unknown_unknown: clang-10
188167
AR_wasm32_unknown_unknown: llvm-ar-10
189168
# TODO: Collect the resultant artifacts and/or run the tests.
190169
run: |
191-
cargo test --no-run -vv ${{ matrix.features }} ${{ matrix.mode }} --target=${{ matrix.target }}
170+
cargo test -vv --no-run --target=${{ matrix.target }} ${{ matrix.features }} ${{ matrix.mode }}
192171
193172
build-cross-apple:
194173
runs-on: ${{ matrix.host_os }}
@@ -206,14 +185,16 @@ jobs:
206185
target:
207186
- aarch64-apple-ios
208187
steps:
188+
- uses: actions/checkout@v2
189+
190+
- run: mk/install-build-tools.sh --target=${{ matrix.target }} ${{ matrix.features }}
191+
209192
- uses: actions-rs/toolchain@v1
210193
with:
211194
override: true
212195
target: ${{ matrix.target }}
213196
toolchain: ${{ matrix.rust_channel }}
214197

215-
- uses: actions/checkout@v2
216-
217198
# TODO: Collect the resultant artifacts and/or run the tests.
218199
- run: |
219200
cargo test --no-run -vv ${{ matrix.features }} ${{ matrix.mode }} --target=${{ matrix.target }}

mk/install-build-tools.sh

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2020 Brian Smith.
4+
#
5+
# Permission to use, copy, modify, and/or distribute this software for any
6+
# purpose with or without fee is hereby granted, provided that the above
7+
# copyright notice and this permission notice appear in all copies.
8+
#
9+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
10+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
12+
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
14+
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
15+
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16+
17+
set -eux -o pipefail
18+
IFS=$'\n\t'
19+
20+
target=$1
21+
features=${2-}
22+
23+
function install_packages {
24+
sudo apt-get -yq --no-install-suggests --no-install-recommends install "$@"
25+
}
26+
27+
case $target in
28+
--target*android*)
29+
mkdir -p "${ANDROID_SDK_ROOT}/licenses"
30+
android_license_file="${ANDROID_SDK_ROOT}/licenses/android-sdk-license"
31+
accept_android_license=24333f8a63b6825ea9c5514f83c2829b004d1fee
32+
grep --quiet --no-messages "$accept_android_license" "$android_license_file" \
33+
|| echo $accept_android_license >> "$android_license_file"
34+
sudo "${ANDROID_SDK_ROOT}/tools/bin/sdkmanager" ndk-bundle
35+
;;
36+
esac
37+
38+
case $target in
39+
--target=aarch64-unknown-linux-gnu)
40+
install_packages \
41+
qemu-user \
42+
gcc-aarch64-linux-gnu \
43+
libc6-dev-arm64-cross
44+
;;
45+
--target=arm-unknown-linux-gnueabihf)
46+
install_packages \
47+
qemu-user \
48+
gcc-arm-linux-gnueabihf \
49+
libc6-dev-armhf-cross
50+
;;
51+
--target=i686-unknown-linux-gnu|--target=i686-unknown-linux-musl)
52+
# TODO: musl i686 shouldn't be using gcc-multilib or libc6-dev-i386.
53+
install_packages \
54+
gcc-multilib \
55+
libc6-dev-i386
56+
;;
57+
--target=wasm32-unknown-unknown)
58+
case ${features-} in
59+
*wasm32_c*)
60+
# "wasm_c" has only been tested with clang-10 and llvm-ar-10. The build
61+
# will fail when using some older versions.
62+
install_packages \
63+
clang-10 \
64+
llvm-10
65+
;;
66+
*)
67+
;;
68+
esac
69+
;;
70+
--target=*)
71+
;;
72+
esac

mk/package.sh

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# This only works on Windows, using MinGW.
32
set -eux -o pipefail
43
IFS=$'\n\t'

0 commit comments

Comments
 (0)