Skip to content

Commit e2d68d2

Browse files
committed
try using cross
1 parent aa23c3c commit e2d68d2

File tree

2 files changed

+41
-21
lines changed

2 files changed

+41
-21
lines changed

.github/workflows/ci.generate.ts

+22-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ enum OperatingSystem {
1010
interface ProfileData {
1111
os: OperatingSystem;
1212
target: string;
13+
cross?: boolean;
1314
runTests?: boolean;
1415
}
1516

@@ -40,6 +41,7 @@ const profileDataItems: ProfileData[] = [{
4041
target: "aarch64-unknown-linux-musl",
4142
}, {
4243
os: OperatingSystem.Linux,
44+
cross: true,
4345
target: "riscv64gc-unknown-linux-gnu",
4446
}];
4547
const profiles = profileDataItems.map((profile) => {
@@ -72,6 +74,7 @@ const ci = {
7274
os: profile.os,
7375
run_tests: (profile.runTests ?? false).toString(),
7476
target: profile.target,
77+
cross: (profile.cross ?? false).toString(),
7578
})),
7679
},
7780
},
@@ -127,33 +130,42 @@ const ci = {
127130
].join("\n"),
128131
},
129132
{
130-
name: "Setup (Linux riscv64gc)",
131-
if: "matrix.config.target == 'riscv64gc-unknown-linux-gnu'",
133+
name: "Setup cross",
134+
if: "matrix.config.cross == 'true'",
132135
run: [
133-
"sudo apt update",
134-
"sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libc6-dev-riscv64-cross",
135-
"rustup target add riscv64gc-unknown-linux-gnu",
136-
"which riscv64-unknown-linux-gnu-gcc"
136+
"cargo install cross --git https://github.com/cross-rs/cross --rev 88f49ff79e777bef6d3564531636ee4d3cc2f8d2",
137137
].join("\n"),
138138
},
139139
{
140140
name: "Build (Debug)",
141-
if: "!startsWith(github.ref, 'refs/tags/')",
141+
if: "matrix.config.cross != 'true' && !startsWith(github.ref, 'refs/tags/')",
142142
env: {
143143
"CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER": "aarch64-linux-gnu-gcc",
144-
"CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER": "riscv64-unknown-linux-gnu-gcc",
145144
},
146145
run: "cargo build --locked --all-targets --target ${{matrix.config.target}}",
147146
},
148147
{
149148
name: "Build release",
150-
if: "startsWith(github.ref, 'refs/tags/')",
149+
if: "matrix.config.cross != 'true' && startsWith(github.ref, 'refs/tags/')",
151150
env: {
152151
"CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER": "aarch64-linux-gnu-gcc",
153-
"CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER": "riscv64-unknown-linux-gnu-gcc",
154152
},
155153
run: "cargo build --locked --all-targets --target ${{matrix.config.target}} --release",
156154
},
155+
{
156+
name: "Build cross (Debug)",
157+
if: "matrix.config.cross == 'true' && !startsWith(github.ref, 'refs/tags/')",
158+
run: [
159+
"cross build --locked --target ${{matrix.config.target}}",
160+
].join("\n"),
161+
},
162+
{
163+
name: "Build cross (Release)",
164+
if: "matrix.config.cross == 'true' && startsWith(github.ref, 'refs/tags/')",
165+
run: [
166+
"cross build --locked --target ${{matrix.config.target}} --release",
167+
].join("\n"),
168+
},
157169
{
158170
name: "Lint",
159171
if:

.github/workflows/ci.yml

+19-11
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,35 @@ jobs:
2323
- os: macos-12
2424
run_tests: 'true'
2525
target: x86_64-apple-darwin
26+
cross: 'false'
2627
- os: macos-latest
2728
run_tests: 'true'
2829
target: aarch64-apple-darwin
30+
cross: 'false'
2931
- os: windows-latest
3032
run_tests: 'true'
3133
target: x86_64-pc-windows-msvc
34+
cross: 'false'
3235
- os: ubuntu-20.04
3336
run_tests: 'true'
3437
target: x86_64-unknown-linux-gnu
38+
cross: 'false'
3539
- os: ubuntu-20.04
3640
run_tests: 'false'
3741
target: x86_64-unknown-linux-musl
42+
cross: 'false'
3843
- os: ubuntu-20.04
3944
run_tests: 'false'
4045
target: aarch64-unknown-linux-gnu
46+
cross: 'false'
4147
- os: ubuntu-20.04
4248
run_tests: 'false'
4349
target: aarch64-unknown-linux-musl
50+
cross: 'false'
4451
- os: ubuntu-20.04
4552
run_tests: 'false'
4653
target: riscv64gc-unknown-linux-gnu
54+
cross: 'true'
4755
outputs:
4856
ZIP_CHECKSUM_X86_64_APPLE_DARWIN: '${{steps.pre_release_x86_64_apple_darwin.outputs.ZIP_CHECKSUM}}'
4957
ZIP_CHECKSUM_AARCH64_APPLE_DARWIN: '${{steps.pre_release_aarch64_apple_darwin.outputs.ZIP_CHECKSUM}}'
@@ -83,25 +91,25 @@ jobs:
8391
sudo apt update
8492
sudo apt install gcc-aarch64-linux-gnu musl musl-dev musl-tools
8593
rustup target add aarch64-unknown-linux-musl
86-
- name: Setup (Linux riscv64gc)
87-
if: matrix.config.target == 'riscv64gc-unknown-linux-gnu'
88-
run: |-
89-
sudo apt update
90-
sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libc6-dev-riscv64-cross
91-
rustup target add riscv64gc-unknown-linux-gnu
92-
which riscv64-unknown-linux-gnu-gcc
94+
- name: Setup cross
95+
if: matrix.config.cross == 'true'
96+
run: 'cargo install cross --git https://github.com/cross-rs/cross --rev 88f49ff79e777bef6d3564531636ee4d3cc2f8d2'
9397
- name: Build (Debug)
94-
if: '!startsWith(github.ref, ''refs/tags/'')'
98+
if: 'matrix.config.cross != ''true'' && !startsWith(github.ref, ''refs/tags/'')'
9599
env:
96100
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
97-
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER: riscv64-unknown-linux-gnu-gcc
98101
run: 'cargo build --locked --all-targets --target ${{matrix.config.target}}'
99102
- name: Build release
100-
if: 'startsWith(github.ref, ''refs/tags/'')'
103+
if: 'matrix.config.cross != ''true'' && startsWith(github.ref, ''refs/tags/'')'
101104
env:
102105
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
103-
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER: riscv64-unknown-linux-gnu-gcc
104106
run: 'cargo build --locked --all-targets --target ${{matrix.config.target}} --release'
107+
- name: Build cross (Debug)
108+
if: 'matrix.config.cross == ''true'' && !startsWith(github.ref, ''refs/tags/'')'
109+
run: 'cross build --locked --target ${{matrix.config.target}}'
110+
- name: Build cross (Release)
111+
if: 'matrix.config.cross == ''true'' && startsWith(github.ref, ''refs/tags/'')'
112+
run: 'cross build --locked --target ${{matrix.config.target}} --release'
105113
- name: Lint
106114
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.config.target == ''x86_64-unknown-linux-gnu'''
107115
run: cargo clippy

0 commit comments

Comments
 (0)