Skip to content

Commit 6037fde

Browse files
authored
ffi download script (#159)
1 parent 22c4b21 commit 6037fde

4 files changed

Lines changed: 95 additions & 55 deletions

File tree

.github/aarch64-docker.dockerfile

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/builds.yml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,44 +62,21 @@ jobs:
6262
submodules: true
6363

6464
- name: Install linux dependencies
65-
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target != 'aarch64-unknown-linux-gnu' }}
65+
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'buildjet-4vcpu-ubuntu-2204-arm'}}
6666
run: |
6767
sudo apt update -y
6868
sudo apt install -y libssl-dev libx11-dev libgl1-mesa-dev libxext-dev
6969
70-
- name: Set up QEMU
71-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
72-
uses: docker/setup-qemu-action@v1
73-
74-
- name: Set up Docker Buildx
75-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
76-
uses: docker/setup-buildx-action@v1
77-
78-
- name: Login to GitHub Container Registry
79-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
80-
uses: docker/login-action@v2
81-
with:
82-
registry: ghcr.io
83-
username: ${{ github.actor }}
84-
password: ${{ secrets.GITHUB_TOKEN }}
85-
8670
- uses: actions-rs/toolchain@v1
8771
with:
8872
toolchain: stable
8973
target: ${{ matrix.target }}
9074

9175
- name: Build (Cargo)
92-
if: ${{ !contains(matrix.target, 'android') && matrix.target != 'aarch64-unknown-linux-gnu' }}
76+
if: ${{ !contains(matrix.target, 'android') }}
9377
run: |
9478
cargo build --release --workspace -p livekit --target ${{ matrix.target }}
9579
96-
- name: Build (Docker)
97-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
98-
run: |
99-
docker buildx create --use
100-
docker buildx build --platform linux/arm64 --load -t lk-arm64:latest -f .github/aarch64-docker.dockerfile .
101-
docker run --rm -v "$(pwd)":/usr/src/app -w /usr/src/app lk-arm64:latest cargo build --release --target aarch64-unknown-linux-gnu
102-
10380
- name: Build (Android)
10481
if: ${{ contains(matrix.target, 'android') }}
10582
run: |

.github/workflows/ffi-builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
platform: android
8484
dylib: liblivekit_ffi.so
8585
target: armv7-linux-androideabi
86-
name: ffi-android-armv7
86+
name: ffi-android-arm
8787
- os: ubuntu-latest
8888
platform: android
8989
dylib: liblivekit_ffi.so

download_ffi.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
# Copyright 2023 LiveKit, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
17+
# This file is used to download prebuilt binaries of livekit-ffi from our GH releases.
18+
# It is mostly used by our bindings (e.g https://github.com/livekit/client-sdk-python)
19+
20+
arch=""
21+
platform=""
22+
version=""
23+
output=""
24+
25+
while [ "$#" -gt 0 ]; do
26+
case "$1" in
27+
--arch)
28+
arch="$2"
29+
if [ "$arch" != "x86_64" ] && [ "$arch" != "arm" ] && [ "$arch" != "arm64" ]; then
30+
echo "Error: Invalid value for --arch. Must be 'x86_64', 'arm' or 'arm64'."
31+
exit 1
32+
fi
33+
shift 2
34+
;;
35+
--platform)
36+
platform="$2"
37+
if [ "$platform" != "windows" ] \
38+
&& [ "$platform" != "linux" ] \
39+
&& [ "$platform" != "macos" ] \
40+
&& [ "$platform" != "ios" ] \
41+
&& [ "$platform" != "android" ]; then
42+
43+
echo "Error: Invalid value for --platform. Must be 'windows', 'linux', 'macos', 'ios' or 'android'."
44+
exit 1
45+
fi
46+
shift 2
47+
;;
48+
--version)
49+
version="$2"
50+
shift 2
51+
;;
52+
--output)
53+
output="$2"
54+
shift 2
55+
;;
56+
*)
57+
echo "Error: Unknown argument '$1'"
58+
exit 1
59+
;;
60+
esac
61+
done
62+
63+
if [ -z "$arch" ]; then
64+
echo "Error: --arch must be set."
65+
exit 1
66+
fi
67+
68+
if [ -z "$platform" ]; then
69+
echo "Error: --platform must be set."
70+
exit 1
71+
fi
72+
73+
if [ -z "$version" ]; then
74+
echo "Error: --version must be set."
75+
exit 1
76+
fi
77+
78+
if [ -z "$output" ]; then
79+
echo "Error: --output must be set."
80+
exit 1
81+
fi
82+
83+
url="https://github.com/livekit/client-sdk-rust/releases/download/ffi-v$version/ffi-$platform-$arch.zip"
84+
echo "Downloading $url"
85+
tmpfile=$(mktemp)
86+
echo "Tmp dir: $tmpfile"
87+
curl $url -L --fail --output $tmpfile
88+
89+
# unzip to output
90+
mkdir -p $output
91+
unzip -o $tmpfile -d $output
92+
rm $tmpfile

0 commit comments

Comments
 (0)