Skip to content

Commit 58cf61b

Browse files
committed
Add CI step that cross-compiles from Linux to macOS/iOS
1 parent 9a9c248 commit 58cf61b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
x86_64-ios-sim,
3030
aarch64-ios-macabi,
3131
x86_64-ios-macabi,
32+
cross-macos-aarch64,
33+
cross-ios-aarch64,
3234
win32,
3335
win64,
3436
mingw32,
@@ -86,6 +88,16 @@ jobs:
8688
rust: stable
8789
target: x86_64-apple-ios-macabi
8890
no_run: --no-run # FIXME(madsmtm): Fix running tests
91+
- build: cross-macos-aarch64
92+
os: ubuntu-latest
93+
rust: stable
94+
target: aarch64-apple-darwin
95+
no_run: --no-run
96+
- build: cross-ios-aarch64
97+
os: ubuntu-latest
98+
rust: stable
99+
target: aarch64-apple-ios
100+
no_run: --no-run
89101
- build: windows-aarch64
90102
os: windows-latest
91103
rust: stable
@@ -155,6 +167,27 @@ jobs:
155167
env:
156168
CC: ${{ matrix.CC }}
157169
CXX: ${{ matrix.CXX }}
170+
- name: Download macOS SDK
171+
if: startsWith(matrix.build, 'cross-macos')
172+
run: |
173+
wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz
174+
tar -xf MacOSX11.3.sdk.tar.xz
175+
echo "SDKROOT=$(pwd)/MacOSX11.3.sdk" >> $GITHUB_ENV
176+
- name: Download iOS SDK
177+
if: startsWith(matrix.build, 'cross-ios')
178+
run: |
179+
wget https://github.com/xybp888/iOS-SDKs/releases/download/iOS18.1-SDKs/iPhoneOS18.1.sdk.zip
180+
unzip iPhoneOS18.1.sdk.zip
181+
echo "SDKROOT=$(pwd)/iPhoneOS18.1.sdk" >> $GITHUB_ENV
182+
- name: Set up Apple cross-compilation
183+
if: startsWith(matrix.build, 'cross-macos') || startsWith(matrix.build, 'cross-ios')
184+
run: |
185+
# Test with clang for now, has better cross-compilation support (GCC requires downloading a different toolchain)
186+
echo "CC=clang" >> $GITHUB_ENV
187+
echo "CXX=clang++" >> $GITHUB_ENV
188+
# Link with rust-lld
189+
UPPERCASE_TARGET_NAME=$(echo "${{ matrix.target }}" | tr '[:lower:]-' '[:upper:]_')
190+
echo "CARGO_TARGET_${UPPERCASE_TARGET_NAME}_LINKER=rust-lld" >> $GITHUB_ENV
158191
- name: setup dev environment
159192
uses: ilammy/msvc-dev-cmd@v1
160193
if: startsWith(matrix.build, 'windows-clang')

0 commit comments

Comments
 (0)