fork/rust-sdks
git clone https://git.julia.blue/fork/rust-sdks
e41cced
main
1# Copyright 2023 LiveKit, Inc. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15name : FFI 16on : 17push : 18branches : [ "main" ] 19tags : 20- "rust-sdks/livekit-ffi@*" 21workflow_dispatch : 22 23env : 24CARGO_TERM_COLOR : always 25 26jobs : 27build : 28strategy : 29fail-fast : false 30matrix : 31include : 32- os : windows-latest 33platform : windows 34dylib : livekit_ffi.dll 35target : x86_64-pc-windows-msvc 36name : ffi-windows-x86_64 37- os : windows-latest 38platform : windows 39dylib : livekit_ffi.dll 40buildargs : --no-default-features --features "native-tls" # ring 0.16 is incompatible with win aarch64 41target : aarch64-pc-windows-msvc 42name : ffi-windows-arm64 43- os : macos-latest 44platform : macos 45dylib : liblivekit_ffi.dylib 46target : x86_64-apple-darwin 47macosx_deployment_target : "10.15" 48name : ffi-macos-x86_64 49- os : macos-latest 50platform : macos 51dylib : liblivekit_ffi.dylib 52target : aarch64-apple-darwin 53macosx_deployment_target : "11.0" # aarch64 requires 11 54name : ffi-macos-arm64 55- os : macos-latest 56platform : ios 57dylib : liblivekit_ffi.a 58target : aarch64-apple-ios 59iphoneos_deployment_target : "13.0" 60name : ffi-ios-arm64 61buildargs : --no-default-features --features "rustls-tls-webpki-roots" 62- os : macos-latest 63platform : ios 64dylib : liblivekit_ffi.a 65target : aarch64-apple-ios-sim 66iphoneos_deployment_target : "13.0" 67name : ffi-ios-sim-arm64 68buildargs : --no-default-features --features "rustls-tls-webpki-roots" 69- os : ubuntu-latest 70platform : linux 71build_image : quay.io/pypa/manylinux_2_28_x86_64 72dylib : liblivekit_ffi.so 73target : x86_64-unknown-linux-gnu 74name : ffi-linux-x86_64 75- os : ubuntu-24.04-arm 76platform : linux 77build_image : quay.io/pypa/manylinux_2_28_aarch64 78dylib : liblivekit_ffi.so 79target : aarch64-unknown-linux-gnu 80name : ffi-linux-arm64 81- os : ubuntu-latest 82platform : android 83dylib : liblivekit_ffi.so 84jar : libwebrtc.jar 85target : aarch64-linux-android 86ndk_arch : aarch64-unknown-linux-musl 87name : ffi-android-arm64 88buildargs : --no-default-features --features "rustls-tls-webpki-roots" 89- os : ubuntu-latest 90platform : android 91dylib : liblivekit_ffi.so 92jar : libwebrtc.jar 93target : armv7-linux-androideabi 94ndk_arch : arm-unknown-linux-musleabihf 95name : ffi-android-armv7 96buildargs : --no-default-features --features "rustls-tls-webpki-roots" 97- os : ubuntu-latest 98platform : android 99dylib : liblivekit_ffi.so 100jar : libwebrtc.jar 101target : x86_64-linux-android 102ndk_arch : x86_64-unknown-linux-musl 103name : ffi-android-x86_64 104buildargs : --no-default-features --features "rustls-tls-webpki-roots" 105 106name : Build (${{ matrix.target }}) 107runs-on : ${{ matrix.os }} 108steps : 109- uses : actions/checkout@v3 110with : 111submodules : true 112 113- uses : actions-rs/toolchain@v1 114with : 115toolchain : stable 116target : ${{ matrix.target }} 117 118- name : Set up QEMU 119if : ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} 120uses : docker/setup-qemu-action@v3 121 122- name : Build (macOS) 123if : ${{ matrix.platform == 'macos' }} 124env : 125MACOSX_DEPLOYMENT_TARGET : ${{ matrix.macosx_deployment_target }} 126run : cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }} 127 128- name : Build (iOS) 129if : ${{ matrix.platform == 'ios' }} 130# TODO(theomonnom): Seems like this is causing issues with the linker (let’s ignore for now) 131#env: 132# IPHONEOS_DEPLOYMENT_TARGET: ${{ matrix.iphoneos_deployment_target }} 133# run: cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }} 134run : cd livekit-ffi && cargo rustc --crate-type staticlib --release --target ${{ matrix.target }} ${{ matrix.buildargs }} 135 136- name : Build (Windows) 137if : ${{ matrix.platform == 'windows' }} 138run : cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }} 139 140# Use Docker on linux, so we can use manylinux images (ensure maximum mcompatibility) 141- name : Build (Linux) 142if : ${{ matrix.platform == 'linux' }} 143run : | 144docker run --rm -v $PWD:/workspace -w /workspace ${{ matrix.build_image }} bash -c "\ 145uname -a; \ 146export PATH=/root/.cargo/bin:\$PATH; \ 147yum install llvm llvm-libs -y; \ 148yum install clang -y; \ 149yum groupinstall 'Development Tools' -y; \ 150clang --version; \ 151yum install openssl-devel libX11-devel mesa-libGL-devel libXext-devel -y; \ 152curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \ 153cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}" 154 155sudo chown -R $USER:$USER target/${{ matrix.target }}/release/ 156 157# on android use cargo ndk 158- name : Build (Android) 159if : ${{ matrix.platform == 'android' }} 160run : | 161cd livekit-ffi/ 162ln -sf $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/lib/${{ matrix.ndk_arch }}/{libunwind.so,libc++abi.a} $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/lib/ 163cargo install cargo-ndk 164cargo ndk --bindgen --target ${{ matrix.target }} build --release ${{ matrix.buildargs }} 165 166- name : Copy/Build licenses 167run : | 168echo "# livekit" > TEMP_LICENSE.md 169echo "```" >> TEMP_LICENSE.md 170cat LICENSE >> TEMP_LICENSE.md 171echo "```" >> TEMP_LICENSE.md 172cat livekit-ffi/WEBRTC_LICENSE.md >> TEMP_LICENSE.md 173mv TEMP_LICENSE.md target/${{ matrix.target }}/release/LICENSE.md 174shell : bash 175 176# zip the files 177- name : Zip artifact (Unix) 178if : ${{ matrix.os != 'windows-latest' && matrix.platform != 'android'}} 179run : | 180cp livekit-ffi/include/livekit_ffi.h target/${{ matrix.target }}/release/ 181cd target/${{ matrix.target }}/release/ 182zip ${{ github.workspace }}/${{ matrix.name }}.zip ${{ matrix.dylib }} livekit_ffi.h LICENSE.md 183 184- name : Zip artifact (Unix for Android) 185if : ${{ matrix.os != 'windows-latest' && matrix.platform == 'android'}} 186run : | 187cp livekit-ffi/include/livekit_ffi.h target/${{ matrix.target }}/release/ 188cd target/${{ matrix.target }}/release/ 189zip ${{ github.workspace }}/${{ matrix.name }}.zip ${{ matrix.dylib }} ${{ matrix.jar }} livekit_ffi.h LICENSE.md 190 191- name : Zip artifact (Windows) 192if : ${{ matrix.os == 'windows-latest' }} 193run : | 194cp livekit-ffi/include/livekit_ffi.h target/${{ matrix.target }}/release/ 195cd target/${{ matrix.target }}/release/ 196Get-ChildItem -Path ${{ matrix.dylib }}, livekit_ffi.h, LICENSE.md | Compress-Archive -DestinationPath ${{ github.workspace }}\${{ matrix.name }}.zip 197 198- name : Upload artifacts 199uses : actions/upload-artifact@v4 200with : 201name : ffi-builds-${{ matrix.target }} 202path : ${{ matrix.name }}.zip 203 204release : 205name : Release to GH (Draft) 206runs-on : ubuntu-latest 207needs : build 208permissions : 209contents : write 210if : startsWith(github.ref, 'refs/tags/rust-sdks/livekit-ffi') 211env : 212GH_TOKEN : ${{ github.token }} 213steps : 214- uses : actions/checkout@v3 215 216- name : Download artifacts 217uses : actions/download-artifact@v4 218with : 219pattern : ffi-builds-* 220merge-multiple : true 221path : ${{ github.workspace }}/ffi-builds 222 223- name : Create draft release 224run : | 225 gh release create ${{ github.ref_name }} --draft --title "${{ github.ref_name }}" 226 gh release upload ${{ github.ref_name }} ${{ github.workspace }}/ffi-builds/*