Skip to content

Commit 943cf97

Browse files
authored
ci: improved ffi builds (#156)
1 parent 91affa5 commit 943cf97

1 file changed

Lines changed: 74 additions & 61 deletions

File tree

.github/workflows/ffi-builds.yml

Lines changed: 74 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
push:
1818
branches: ["main"]
1919
workflow_dispatch:
20+
2021
env:
2122
CARGO_TERM_COLOR: always
2223

@@ -27,40 +28,67 @@ jobs:
2728
matrix:
2829
include:
2930
- os: windows-latest
31+
platform: windows
3032
dylib: livekit_ffi.dll
3133
target: x86_64-pc-windows-msvc
34+
name: ffi-windows-x86_64
3235
- os: windows-latest
36+
platform: windows
3337
dylib: livekit_ffi.dll
34-
# due to ring 0.16 compatibilities with win aarch64, we need to use native-tls instead of rustls
35-
buildargs: --no-default-features --features "native-tls"
38+
buildargs: --no-default-features --features "native-tls" # ring 0.16 is incompatible with win aarch64
3639
target: aarch64-pc-windows-msvc
40+
name: ffi-windows-arm64
3741
- os: macos-latest
42+
platform: macos
3843
dylib: liblivekit_ffi.dylib
3944
target: x86_64-apple-darwin
45+
macosx_deployment_target: "10.11"
46+
name: ffi-macos-x86_64
4047
- os: macos-latest
48+
platform: macos
4149
dylib: liblivekit_ffi.dylib
42-
target: aarch64-apple-ios
50+
target: aarch64-apple-darwin
51+
macosx_deployment_target: "11.0" # aarch64 requires 11
52+
name: ffi-macos-arm64
4353
- os: macos-latest
54+
platform: ios
4455
dylib: liblivekit_ffi.dylib
45-
target: aarch64-apple-ios-sim
56+
target: aarch64-apple-ios
57+
iphoneos_deployment_target: "13.0"
58+
name: ffi-ios-arm64
4659
- os: macos-latest
60+
platform: ios
4761
dylib: liblivekit_ffi.dylib
48-
target: aarch64-apple-darwin
49-
- os: ubuntu-20.04
62+
target: aarch64-apple-ios-sim
63+
iphoneos_deployment_target: "13.0"
64+
name: ffi-ios-sim-arm64
65+
- os: ubuntu-latest
66+
platform: linux
67+
build_image: quay.io/pypa/manylinux2014_x86_64
5068
dylib: liblivekit_ffi.so
5169
target: x86_64-unknown-linux-gnu
70+
name: ffi-linux-x86_64
5271
- os: buildjet-4vcpu-ubuntu-2204-arm
72+
platform: linux
73+
build_image: quay.io/pypa/manylinux2014_aarch64
5374
dylib: liblivekit_ffi.so
5475
target: aarch64-unknown-linux-gnu
55-
- os: ubuntu-20.04
76+
name: ffi-linux-arm64
77+
- os: ubuntu-latest
78+
platform: android
5679
dylib: liblivekit_ffi.so
5780
target: aarch64-linux-android
58-
- os: ubuntu-20.04
81+
name: ffi-android-arm64
82+
- os: ubuntu-latest
83+
platform: android
5984
dylib: liblivekit_ffi.so
6085
target: armv7-linux-androideabi
61-
- os: ubuntu-20.04
86+
name: ffi-android-armv7
87+
- os: ubuntu-latest
88+
platform: android
6289
dylib: liblivekit_ffi.so
6390
target: x86_64-linux-android
91+
name: ffi-android-x86_64
6492

6593
name: Build (${{ matrix.target }})
6694
runs-on: ${{ matrix.os }}
@@ -69,78 +97,63 @@ jobs:
6997
with:
7098
submodules: true
7199

72-
- name: Setup vars
73-
id: setup
74-
run: |
75-
echo "ZIP=liblivekit_ffi-${{ matrix.target }}.zip" >> "$GITHUB_OUTPUT"
76-
shell: bash
77-
78-
- name: Info
79-
run: |
80-
echo "OutZip: ${{ steps.setup.outputs.ZIP }}"
81-
82100
- uses: actions-rs/toolchain@v1
83101
with:
84102
toolchain: stable
85103
target: ${{ matrix.target }}
86104

87-
- name: Install linux dependencies
88-
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.target != 'aarch64-unknown-linux-gnu' }}
105+
- name: Build (macOS)
106+
if: ${{ matrix.platform == 'macos' }}
107+
env:
108+
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
109+
run: cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}
110+
111+
- name: Build (iOS)
112+
if: ${{ matrix.platform == 'ios' }}
113+
# TODO(theomonnom): Seems like this is causing issues with the linker (let’s ignore for now)
114+
#env:
115+
# IPHONEOS_DEPLOYMENT_TARGET: ${{ matrix.iphoneos_deployment_target }}
116+
run: cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}
117+
118+
- name: Build (Windows)
119+
if: ${{ matrix.platform == 'windows' }}
120+
run: cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}
121+
122+
# Use Docker on linux, so we can use manylinux images (ensure maximum mcompatibility)
123+
- name: Build (Linux)
124+
if: ${{ matrix.platform == 'linux' }}
89125
run: |
90-
sudo apt update -y
91-
sudo apt install -y libssl-dev libx11-dev libgl1-mesa-dev libxext-dev
92-
93-
- name: Set up QEMU
94-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
95-
uses: docker/setup-qemu-action@v1
96-
97-
- name: Set up Docker Buildx
98-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
99-
uses: docker/setup-buildx-action@v1
100-
101-
- name: Login to GitHub Container Registry
102-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
103-
uses: docker/login-action@v2
104-
with:
105-
registry: ghcr.io
106-
username: ${{ github.actor }}
107-
password: ${{ secrets.GITHUB_TOKEN }}
108-
109-
- name: Build (Cargo)
110-
if: ${{ !contains(matrix.target, 'android') && matrix.target != 'aarch64-unknown-linux-gnu' }}
111-
run: |
112-
cd livekit-ffi/
113-
cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}
114-
115-
- name: Build (Docker)
116-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
117-
run: |
118-
docker buildx create --use
119-
docker buildx build --platform linux/arm64 --load -t lk-arm64:latest -f .github/aarch64-docker.dockerfile .
120-
docker run --rm -v "$(pwd)":/usr/src/app -w /usr/src/app lk-arm64:latest sh -c 'cd livekit-ffi && cargo build --release --target aarch64-unknown-linux-gnu ${{ matrix.buildargs }}'
121-
126+
docker run --rm -v $PWD:/workspace -w /workspace ${{ matrix.build_image }} bash -c "\
127+
uname -a; \
128+
export PATH=/root/.cargo/bin:\$PATH; \
129+
yum install openssl-devel libX11-devel mesa-libGL-devel libXext-devel -y; \
130+
curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
131+
cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}"
132+
133+
# on android use cargo ndk
122134
- name: Build (Android)
123-
if: ${{ contains(matrix.target, 'android') }}
135+
if: ${{ matrix.platform == 'android' }}
124136
run: |
125137
cd livekit-ffi/
126138
cargo install cargo-ndk
127-
cargo ndk --target ${{ matrix.target }} build --release ${{ matrix.buildargs }}
139+
cargo ndk --target ${{ matrix.target }} build --release ${{ matrix.buildargs }}
128140
141+
# zip the files
129142
- name: Zip artifact (Unix)
130143
if: ${{ matrix.os != 'windows-latest' }}
131144
run: |
132-
cd target/${{ matrix.target }}/release/
133-
zip ${{ github.workspace }}/${{ steps.setup.outputs.ZIP }} ${{ matrix.dylib }}
145+
zip ${{ github.workspace }}/${{ matrix.name }}.zip target/${{ matrix.target }}/release/${{ matrix.dylib }} \
146+
livekit-ffi/include/livekit_ffi.h
134147
135148
- name: Zip artifact (Windows)
136149
if: ${{ matrix.os == 'windows-latest' }}
137150
run: |
151+
cp livekit-ffi/include/livekit_ffi.h target/${{ matrix.target }}/release/
138152
cd target/${{ matrix.target }}/release/
139-
Compress-Archive -Path ${{ matrix.dylib }} -DestinationPath ${{ github.workspace }}\${{ steps.setup.outputs.ZIP }}
153+
Get-ChildItem -Path ${{ matrix.dylib }}, livekit_ffi.h | Compress-Archive -DestinationPath ${{ github.workspace }}\${{ matrix.name }}.zip
140154
141-
# doublezip here but I don't think there is an alternative
142155
- name: Upload artifacts
143156
uses: actions/upload-artifact@v3
144157
with:
145-
name: ${{ steps.setup.outputs.ZIP }}
146-
path: ${{ steps.setup.outputs.ZIP }}
158+
name: ${{ matrix.name }}.zip
159+
path: ${{ matrix.name }}.zip

0 commit comments

Comments
 (0)