Skip to content

Commit e01b283

Browse files
committed
Update CI to build all matrix targets
This adds the matrix `--target` to relevant `cargo` commands. Some targets are now “check-only”, which confirms cross-compilation succeeds, without doing a full test run, because running these tests may require emulation. musl and MinGW have been dropped, because musl has no standard C++ setup, and MinGW isn’t a target for us. All this requires some adjustments to boring-sys: - Blocklist max_align_t in bindgen - rust-lang/rust-bindgen#1823 - Don't check for MSVC with target_env - x86_64-pc-windows-gnu is identified as `target_env = "msvc"` too, but doesn't use the Visual Studio CMake generator.
1 parent 8d4822b commit e01b283

File tree

2 files changed

+63
-27
lines changed

2 files changed

+63
-27
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ jobs:
6767
matrix:
6868
thing:
6969
- stable
70-
- macos-x86_64
7170
- arm-android
7271
- arm64-android
7372
- i686-android
@@ -78,72 +77,99 @@ jobs:
7877
- i686-linux
7978
- arm-linux
8079
- aarch64-linux
81-
- x86_64-musl
82-
- x86_64-mingw
80+
- arm64-macos
81+
- x86_64-macos
8382
- i686-msvc
8483
- x86_64-msvc
8584
include:
85+
- check_only: false
86+
- extra_test_args: ''
87+
- apt_packages: ''
88+
- custom_env: {}
8689
- thing: stable
8790
target: x86_64-unknown-linux-gnu
8891
rust: stable
8992
os: ubuntu-latest
90-
- thing: macos-x86_64
91-
target: x86_64-apple-darwin
92-
rust: stable
93-
os: macos-latest
9493
- thing: arm-android
95-
target: arm-linux-androideabi
94+
target: armv7-linux-androideabi
9695
rust: stable
9796
os: ubuntu-latest
97+
check_only: true
9898
- thing: arm64-android
9999
target: aarch64-linux-android
100100
rust: stable
101101
os: ubuntu-latest
102+
check_only: true
102103
- thing: i686-android
103104
target: i686-linux-android
104105
rust: stable
105106
os: ubuntu-latest
107+
check_only: true
106108
- thing: x86_64-android
107109
target: x86_64-linux-android
108110
rust: stable
109111
os: ubuntu-latest
112+
check_only: true
110113
- thing: aarch64-ios
111114
target: aarch64-apple-ios
112115
os: macos-latest
116+
check_only: true
117+
# It's... theoretically possible to run tests on iPhone Simulator,
118+
# but for now, make sure that BoringSSL only builds.
113119
- thing: aarch64-ios-sim
114120
target: aarch64-apple-ios-sim
115121
os: macos-latest
122+
check_only: true
116123
- thing: x86_64-ios
117124
target: x86_64-apple-ios
118125
os: macos-latest
126+
check_only: true
119127
- thing: i686-linux
120128
target: i686-unknown-linux-gnu
121129
rust: stable
122130
os: ubuntu-latest
131+
apt_packages: gcc-multilib g++-multilib
123132
- thing: arm-linux
124133
target: arm-unknown-linux-gnueabi
125134
rust: stable
126135
os: ubuntu-latest
136+
apt_packages: gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
137+
check_only: true
138+
custom_env:
139+
CC: arm-linux-gnueabi-gcc
140+
CXX: arm-linux-gnueabi-g++
141+
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER: arm-linux-gnueabi-g++
127142
- thing: aarch64-linux
128143
target: aarch64-unknown-linux-gnu
129144
rust: stable
130145
os: ubuntu-latest
131-
- thing: x86_64-musl
132-
target: x86_64-unknown-linux-musl
146+
apt_packages: crossbuild-essential-arm64
147+
check_only: true
148+
custom_env:
149+
CC: aarch64-linux-gnu-gcc
150+
CXX: aarch64-linux-gnu-g++
151+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++
152+
- thing: arm64-macos
153+
target: aarch64-apple-darwin
133154
rust: stable
134-
os: ubuntu-latest
135-
- thing: x86_64-mingw
136-
target: x86_64-pc-windows-gnu
155+
os: macos-latest
156+
check_only: true
157+
- thing: x86_64-macos
158+
target: x86_64-apple-darwin
137159
rust: stable
138-
os: ubuntu-latest
160+
os: macos-latest
139161
- thing: i686-msvc
140162
target: i686-pc-windows-msvc
141163
rust: stable-x86_64-msvc
142164
os: windows-latest
165+
# CI's Windows doesn't have required root certs
166+
extra_test_args: --workspace --exclude tokio-boring --exclude hyper-boring
143167
- thing: x86_64-msvc
144168
target: x86_64-pc-windows-msvc
145169
rust: stable-x86_64-msvc
146170
os: windows-latest
171+
# CI's Windows doesn't have required root certs
172+
extra_test_args: --workspace --exclude tokio-boring --exclude hyper-boring
147173

148174
steps:
149175
- uses: actions/checkout@v2
@@ -153,6 +179,10 @@ jobs:
153179
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
154180
shell: bash
155181
- run: rustup target add ${{ matrix.target }}
182+
- name: Install target-specific APT dependencies
183+
if: "matrix.apt_packages != ''"
184+
run: sudo apt update && sudo apt install -y ${{ matrix.apt_packages }}
185+
shell: bash
156186
- name: Install nasm
157187
if: startsWith(matrix.os, 'windows')
158188
run: choco install nasm
@@ -166,18 +196,20 @@ jobs:
166196
- name: Set LIBCLANG_PATH
167197
if: startsWith(matrix.os, 'windows')
168198
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
169-
- if: "startsWith(matrix.os, 'windows') && !contains(matrix.target, 'ios')"
170-
# CI's Windows doesn't have require root certs
171-
run: cargo test --workspace --exclude tokio-boring --exclude hyper-boring
172-
name: Run tests (Windows)
173-
- if: "!startsWith(matrix.os, 'windows') && !contains(matrix.target, 'ios')"
174-
run: cargo test
175-
name: Run tests (not Windows)
176-
- if: "contains(matrix.target, 'ios')"
177-
# It's... theoretically possible to run tests on iPhone Simulator,
178-
# but for now, make sure that BoringSSL only builds.
179-
run: cargo check --target ${{ matrix.target }} --all-targets
180-
name: Check tests (iOS)
199+
- name: Set Android Linker path
200+
if: endsWith(matrix.thing, '-android')
201+
run: echo "CARGO_TARGET_$(echo ${{ matrix.target }} | tr \\-a-z _A-Z)_LINKER=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/$(echo ${{ matrix.target }} | sed s/armv7/armv7a/)21-clang++" >> "$GITHUB_ENV"
202+
- if: "!matrix.check_only"
203+
run: cargo test --target ${{ matrix.target }} ${{ matrix.extra_test_args }}
204+
name: Run tests
205+
shell: bash
206+
env: ${{ matrix.custom_env }}
207+
- if: matrix.check_only
208+
# We `build` because we want the linker to verify we are cross-compiling correctly.
209+
run: cargo build --target ${{ matrix.target }} --tests
210+
name: Build tests
211+
shell: bash
212+
env: ${{ matrix.custom_env }}
181213
- name: Test boring-sys cargo publish
182214
# Running `cargo publish --dry-run` tests two things:
183215
#

boring-sys/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ fn get_boringssl_source_path() -> String {
168168
/// so adjust library location based on platform and build target.
169169
/// See issue: https://github.com/alexcrichton/cmake-rs/issues/18
170170
fn get_boringssl_platform_output_path() -> String {
171-
if cfg!(target_env = "msvc") {
171+
if env::var("TARGET")
172+
.expect("TARGET variable not defined in env")
173+
.ends_with("-msvc")
174+
{
172175
// Code under this branch should match the logic in cmake-rs
173176
let debug_env_var = env::var("DEBUG").expect("DEBUG variable not defined in env");
174177

@@ -680,6 +683,7 @@ fn main() {
680683
.size_t_is_usize(true)
681684
.layout_tests(true)
682685
.prepend_enum_name(true)
686+
.blocklist_type("max_align_t") // Not supported by bindgen on all targets, not used by BoringSSL
683687
.clang_args(get_extra_clang_args_for_bindgen())
684688
.clang_args(&["-I", &include_path]);
685689

0 commit comments

Comments
 (0)