Skip to content

Commit 39f2ed9

Browse files
committed
ci: use 'cross' for cross compilation
1 parent 7947c2f commit 39f2ed9

File tree

3 files changed

+21
-39
lines changed

3 files changed

+21
-39
lines changed

.github/workflows/test.yaml

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
target: x86_64-unknown-linux-gnu
4141
- os: ubuntu-latest
4242
target: aarch64-unknown-linux-gnu
43+
cross: true
4344
- os: macos-latest
4445
target: x86_64-apple-darwin
4546
- os: macos-latest
@@ -65,46 +66,23 @@ jobs:
6566
run: |
6667
sudo apt-get update
6768
sudo apt-get install -y \
68-
pkg-config \
69-
libssl-dev \
7069
gcc-aarch64-linux-gnu \
7170
libc6-dev-arm64-cross \
7271
crossbuild-essential-arm64
7372
74-
- name: Setup cross-compilation environment
75-
if: matrix.target.os == 'ubuntu-latest' && matrix.target.target == 'aarch64-unknown-linux-gnu'
73+
- name: Install cross
74+
if: matrix.target.cross
7675
run: |
77-
# Install cross-compilation tools for ARM64
78-
sudo apt-get install -y \
79-
gcc-aarch64-linux-gnu \
80-
g++-aarch64-linux-gnu \
81-
libc6-dev-arm64-cross \
82-
gcc-13-aarch64-linux-gnu
83-
84-
# Set up cross-compilation environment variables
85-
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
86-
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
87-
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV
88-
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
89-
90-
# Set up OpenSSL for cross-compilation (using host libraries)
91-
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
92-
echo "OPENSSL_DIR=/usr" >> $GITHUB_ENV
93-
echo "OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV
94-
echo "OPENSSL_INCLUDE_DIR=/usr/include" >> $GITHUB_ENV
95-
96-
- name: Setup native Linux environment
97-
if: matrix.target.os == 'ubuntu-latest' && matrix.target.target == 'x86_64-unknown-linux-gnu'
98-
run: |
99-
# Ensure native build has proper OpenSSL setup
100-
echo "OPENSSL_DIR=/usr" >> $GITHUB_ENV
101-
echo "OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV
102-
echo "OPENSSL_INCLUDE_DIR=/usr/include" >> $GITHUB_ENV
76+
cargo install cross --git https://github.com/cross-rs/cross
10377
10478
- name: Install macOS dependencies
10579
if: matrix.target.os == 'macos-latest'
10680
run: |
10781
brew install pkg-config openssl@3
108-
109-
- name: Build project
82+
- name: Build project (native)
83+
if: ${{ !matrix.target.cross }} # default to false if not set
11084
run: cargo build --target ${{ matrix.target.target }} --features ${{ matrix.feature }}
85+
86+
- name: Build project (cross-compilation)
87+
if: matrix.target.cross
88+
run: cross build --release --target=${{ matrix.target.target }} --features ${{ matrix.feature }},vendored-openssl

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ categories = ["command-line-utilities", "web-programming"]
1313
default = ["cli"]
1414
cli = ["clap"]
1515
server = []
16+
vendored-openssl = ["reqwest/native-tls-vendored"]
1617

1718
[dependencies]
1819
anyhow = "1.0.98"
@@ -35,15 +36,8 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
3536
thiserror = "2.0.12"
3637
serde_json = "1.0.142"
3738

38-
39-
40-
4139
[build-dependencies]
4240
phf_codegen = "0.12.1"
4341
serde = { version = "1.0.204", features = ["derive"] }
4442
saphyr = "0.0.6"
4543
reqwest = { version = "0.12.5", features = ["blocking"] }
46-
47-
48-
49-

0 commit comments

Comments
 (0)