Skip to content

Commit 06214b6

Browse files
committed
Build libsignal-ffi for all platforms
1 parent 865d879 commit 06214b6

File tree

11 files changed

+149
-1516
lines changed

11 files changed

+149
-1516
lines changed

.github/workflows/README.md

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

.github/workflows/build.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- '*'
8+
9+
defaults:
10+
run:
11+
shell: 'bash'
12+
13+
env:
14+
RUSTFLAGS: '-Awarnings -Ctarget-feature=-crt-static --cfg aes_armv8 --cfg polyval_armv8 --cfg curve25519_dalek_bits="64"'
15+
IPHONEOS_DEPLOYMENT_TARGET: 17.0
16+
17+
jobs:
18+
libsignal-ffi:
19+
runs-on: ${{ matrix.runs-on }}
20+
strategy:
21+
fail-fast: true
22+
matrix:
23+
include:
24+
- target: aarch64-apple-ios
25+
runs-on: macos-latest
26+
- target: aarch64-apple-ios-sim
27+
runs-on: macos-latest
28+
- target: x86_64-apple-ios
29+
runs-on: macos-latest
30+
31+
- target: x86_64-apple-darwin
32+
runs-on: macos-latest
33+
- target: aarch64-apple-darwin
34+
runs-on: macos-latest
35+
- target: x86_64-unknown-linux-gnu
36+
runs-on: ubuntu-latest
37+
- target: aarch64-unknown-linux-gnu
38+
runs-on: ubuntu-arm64
39+
- target: x86_64-pc-windows-gnu
40+
runs-on: windows-latest
41+
# This is missing bash? https://github.com/actions/partner-runner-images/issues/55
42+
#- target: aarch64-pc-windows-gnu
43+
# runs-on: windows-arm64
44+
45+
- target: aarch64-linux-android
46+
android-prefix: aarch64-linux-android
47+
android-env: aarch64_linux_android
48+
runs-on: ubuntu-latest
49+
- target: armv7-linux-androideabi
50+
android-prefix: armv7a-linux-androideabi # same as target, but has "a" after v7
51+
android-env: armv7_linux_androideabi # same as target, but with underscores
52+
runs-on: ubuntu-latest
53+
- target: i686-linux-android
54+
android-prefix: i686-linux-android
55+
android-env: i686_linux_android
56+
runs-on: ubuntu-latest
57+
- target: x86_64-linux-android
58+
android-prefix: x86_64-linux-android
59+
android-env: x86_64_linux_android
60+
runs-on: ubuntu-latest
61+
name: libsignal-ffi (${{ matrix.target }})
62+
63+
steps:
64+
- name: Clone repository
65+
uses: actions/checkout@v4
66+
67+
- name: Setup Rust
68+
uses: actions-rust-lang/setup-rust-toolchain@v1
69+
70+
- name: Install Protoc
71+
uses: arduino/setup-protoc@v3
72+
with:
73+
repo-token: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Set up JDK 17
76+
if: contains(matrix.target, 'android')
77+
uses: actions/setup-java@v4
78+
with:
79+
distribution: 'temurin'
80+
java-version: '17'
81+
cache: 'gradle'
82+
83+
- name: Setup Android SDK
84+
if: contains(matrix.target, 'android')
85+
uses: android-actions/setup-android@v3
86+
with:
87+
packages: 'tools platform-tools ndk;26.1.10909125'
88+
89+
- name: Install winget for Windows
90+
if: runner.os == 'Windows'
91+
uses: Cyberboss/install-winget@v1
92+
93+
- name: Install NASM for Windows
94+
if: runner.os == 'Windows'
95+
run: |
96+
winget install nasm --accept-package-agreements --accept-source-agreements --disable-interactivity --silent
97+
98+
- uses: maxim-lobanov/setup-xcode@v1
99+
if: runner.os == 'macOS'
100+
with:
101+
xcode-version: 'latest-stable'
102+
103+
- name: build libsignal
104+
run: |
105+
if [[ "${{matrix.target}}" = *"android"* ]]; then
106+
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125
107+
export API_LEVEL=26
108+
export HOST_PREFIX=linux-x86_64
109+
export AR_${{ matrix.android-env }}=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$HOST_PREFIX/bin/llvm-ar
110+
export CC_${{ matrix.android-env }}=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$HOST_PREFIX/bin/${{ matrix.android-prefix }}${API_LEVEL}-clang
111+
declare -u ANDROID_ENV_UPPER=${{ matrix.android-env }}
112+
export CARGO_TARGET_${ANDROID_ENV_UPPER}_LINKER=$CC_${{ matrix.android-env }}
113+
114+
# TODO should these be enabled for all platforms? They're copied from the old android build
115+
export CLFAGS="-DOPENSSL_SMALL -flto=full"
116+
export CARGO_PROFILE_RELEASE_LTO=fat
117+
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
118+
export CARGO_PROFILE_RELEASE_DEBUG=1
119+
export CARGO_PROFILE_RELEASE_OPT_LEVEL=1
120+
fi
121+
if [ "${{ runner.os }}" = "Windows" ]; then
122+
rustup set default-host ${{ matrix.target }}
123+
fi
124+
rustup target add ${{ matrix.target }}
125+
cargo build --locked --target ${{ matrix.target }} -p libsignal-ffi --profile=release
126+
mv target/${{ matrix.target }}/release/libsignal_ffi.a libsignal_ffi_${{ matrix.target }}.a
127+
128+
- name: Upload artifacts
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: libsignal_ffi_${{ matrix.target }}
132+
path: libsignal_ffi_${{ matrix.target }}.a
133+
134+
release:
135+
runs-on: ubuntu-latest
136+
needs: libsignal-ffi
137+
if: startsWith(github.ref, 'refs/tags/')
138+
steps:
139+
- name: Clone repository
140+
uses: actions/checkout@v4
141+
- name: Download artifacts
142+
uses: actions/download-artifact@v4
143+
- name: Move artifacts to top level
144+
run: mv libsignal_ffi_*/libsignal_ffi_*.a .
145+
- name: Create release
146+
uses: softprops/action-gh-release@v2
147+
with:
148+
body_path: RELEASE_NOTES.md
149+
files: libsignal_ffi_*.a

0 commit comments

Comments
 (0)