Skip to content

Commit 7acfd2e

Browse files
fix build actions:
1 parent 282242f commit 7acfd2e

File tree

1 file changed

+74
-52
lines changed

1 file changed

+74
-52
lines changed

.github/workflows/build.yaml

Lines changed: 74 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,42 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
include:
18-
# Linux builds
18+
# Linux builds - x86_64 native, aarch64 cross-compile
1919
- os: ubuntu-latest
2020
target: x86_64-unknown-linux-gnu
21+
use_cross: false
2122
- os: ubuntu-latest
2223
target: aarch64-unknown-linux-gnu
23-
# macOS builds
24+
use_cross: true
25+
# macOS builds - both native on macos-latest (M1)
2426
- os: macos-latest
2527
target: x86_64-apple-darwin
28+
use_cross: false
2629
- os: macos-latest
2730
target: aarch64-apple-darwin
31+
use_cross: false
2832
# Windows build
2933
- os: windows-latest
3034
target: x86_64-pc-windows-msvc
35+
use_cross: false
3136
steps:
3237
- uses: actions/checkout@v4
38+
3339
- name: Setup Rust toolchain
3440
uses: dtolnay/rust-toolchain@stable
3541
with:
3642
targets: ${{ matrix.target }}
43+
3744
- name: Install GCC 11 on Linux
3845
if: runner.os == 'Linux'
3946
run: |
4047
sudo apt-get update
4148
sudo apt-get install -y gcc-11 g++-11
42-
- name: Set CC and CXX to gcc-11
43-
if: runner.os == 'Linux'
44-
run: |
45-
echo "CC=gcc-11" >> $GITHUB_ENV
46-
echo "CXX=g++-11" >> $GITHUB_ENV
49+
50+
- name: Install cross
51+
if: matrix.use_cross
52+
run: cargo install cross --git https://github.com/cross-rs/cross
53+
4754
- name: Cache dependencies
4855
uses: actions/cache@v4
4956
with:
@@ -52,12 +59,18 @@ jobs:
5259
~/.cargo/git
5360
target
5461
key: ${{ runner.os }}-cargo-${{ matrix.target }}-default-${{ hashFiles('**/Cargo.lock') }}
55-
- name: Build
56-
uses: actions-rs/cargo@v1
57-
with:
58-
use-cross: ${{ runner.os == 'Linux' }}
59-
command: build
60-
args: --target ${{ matrix.target }} --release
62+
63+
- name: Build with cross
64+
if: matrix.use_cross
65+
run: cross build --target ${{ matrix.target }} --release
66+
67+
- name: Build native
68+
if: ${{ !matrix.use_cross }}
69+
env:
70+
CC: ${{ runner.os == 'Linux' && 'gcc-11' || '' }}
71+
CXX: ${{ runner.os == 'Linux' && 'g++-11' || '' }}
72+
run: cargo build --target ${{ matrix.target }} --release
73+
6174
# Kafka build for supported platforms
6275
build-kafka:
6376
name: Build Kafka ${{matrix.target}}
@@ -66,19 +79,29 @@ jobs:
6679
fail-fast: false
6780
matrix:
6881
include:
69-
# Linux builds
82+
# Linux x86_64 - native build
7083
- os: ubuntu-latest
7184
target: x86_64-unknown-linux-gnu
85+
use_cross: false
86+
# Linux aarch64 - cross-compile
87+
- os: ubuntu-latest
88+
target: aarch64-unknown-linux-gnu
89+
use_cross: true
90+
# macOS aarch64 - native on M1
7291
- os: macos-latest
7392
target: aarch64-apple-darwin
93+
use_cross: false
7494
steps:
7595
- uses: actions/checkout@v4
76-
# Linux-specific dependencies
77-
- name: Install Linux dependencies
78-
if: runner.os == 'Linux'
96+
97+
# Linux-specific dependencies for native x86_64 build
98+
- name: Install Linux dependencies (x86_64)
99+
if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu'
79100
run: |
80101
sudo apt-get update
81102
sudo apt-get install -y \
103+
gcc-11 \
104+
g++-11 \
82105
build-essential \
83106
pkg-config \
84107
cmake \
@@ -88,29 +111,23 @@ jobs:
88111
liblz4-dev \
89112
libssl-dev \
90113
libsasl2-dev \
91-
python3 \
92-
gcc-aarch64-linux-gnu \
93-
g++-aarch64-linux-gnu
94-
# Install cross-compilation specific packages
95-
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
96-
sudo apt-get install -y \
97-
gcc-aarch64-linux-gnu \
98-
g++-aarch64-linux-gnu \
99-
libc6-dev-arm64-cross \
100-
libsasl2-dev:arm64 \
101-
libssl-dev:arm64 \
102-
pkg-config-aarch64-linux-gnu
103-
fi
104-
- name: Install GCC 11 on Linux
105-
if: runner.os == 'Linux'
114+
python3
115+
116+
# Linux dependencies for aarch64 cross-compilation
117+
- name: Install Linux dependencies (aarch64 cross)
118+
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
106119
run: |
107120
sudo apt-get update
108-
sudo apt-get install -y gcc-11 g++-11
109-
- name: Set CC and CXX to gcc-11
110-
if: runner.os == 'Linux'
111-
run: |
112-
echo "CC=gcc-11" >> $GITHUB_ENV
113-
echo "CXX=g++-11" >> $GITHUB_ENV
121+
sudo apt-get install -y \
122+
gcc-11 \
123+
g++-11 \
124+
build-essential \
125+
pkg-config \
126+
cmake \
127+
clang \
128+
gcc-aarch64-linux-gnu \
129+
g++-aarch64-linux-gnu
130+
114131
# macOS-specific dependencies
115132
- name: Install macOS dependencies
116133
if: runner.os == 'macOS'
@@ -123,10 +140,16 @@ jobs:
123140
124141
cyrus-sasl \
125142
python3
143+
126144
- name: Setup Rust toolchain
127145
uses: dtolnay/rust-toolchain@stable
128146
with:
129147
targets: ${{ matrix.target }}
148+
149+
- name: Install cross
150+
if: matrix.use_cross
151+
run: cargo install cross --git https://github.com/cross-rs/cross
152+
130153
- name: Cache dependencies
131154
uses: actions/cache@v4
132155
with:
@@ -135,8 +158,9 @@ jobs:
135158
~/.cargo/git
136159
target
137160
key: ${{ runner.os }}-cargo-${{ matrix.target }}-kafka-${{ hashFiles('**/Cargo.lock') }}
161+
138162
- name: Find and fix librdkafka CMakeLists.txt for Linux
139-
if: runner.os == 'Linux'
163+
if: runner.os == 'Linux' && !matrix.use_cross
140164
run: |
141165
cargo fetch
142166
# Find the rdkafka-sys package directory
@@ -156,6 +180,7 @@ jobs:
156180
echo "Could not find librdkafka CMakeLists.txt file!"
157181
exit 1
158182
fi
183+
159184
- name: Find and fix librdkafka CMakeLists.txt for macOS
160185
if: runner.os == 'macOS'
161186
run: |
@@ -177,18 +202,15 @@ jobs:
177202
echo "Could not find librdkafka CMakeLists.txt file!"
178203
exit 1
179204
fi
180-
- name: Build with Kafka
181-
uses: actions-rs/cargo@v1
182-
with:
183-
use-cross: ${{ runner.os == 'Linux' }}
184-
command: build
185-
args: --target ${{ matrix.target }} --features kafka --release
205+
206+
- name: Build with Kafka (cross)
207+
if: matrix.use_cross
208+
run: cross build --target ${{ matrix.target }} --features kafka --release
209+
210+
- name: Build with Kafka (native)
211+
if: ${{ !matrix.use_cross }}
186212
env:
213+
CC: ${{ runner.os == 'Linux' && 'gcc-11' || '' }}
214+
CXX: ${{ runner.os == 'Linux' && 'g++-11' || '' }}
187215
LIBRDKAFKA_SSL_VENDORED: 1
188-
PKG_CONFIG_ALLOW_CROSS: "1"
189-
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
190-
SASL2_DIR: /usr/lib/aarch64-linux-gnu
191-
OPENSSL_DIR: /usr/lib/aarch64-linux-gnu
192-
OPENSSL_ROOT_DIR: /usr/lib/aarch64-linux-gnu
193-
OPENSSL_STATIC: "1"
194-
SASL2_STATIC: "0"
216+
run: cargo build --target ${{ matrix.target }} --features kafka --release

0 commit comments

Comments
 (0)