Skip to content

Commit c891984

Browse files
committed
chore: Add native library deploy workflow.
1 parent b641b56 commit c891984

12 files changed

+167
-328
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66
branches: [master]
77

8-
# Cancel old PR builds when pushing new commits.
8+
# Cancel old builds when pushing new commits.
99
concurrency:
1010
group: build-${{ github.event.pull_request.number || github.ref }}
1111
cancel-in-progress: true

.github/workflows/deploy.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
name: deploy
3+
4+
on:
5+
push:
6+
branches: [master]
7+
pull_request:
8+
branches: [master]
9+
10+
# Cancel old builds when pushing new commits.
11+
concurrency:
12+
group: deploy-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
linux:
17+
name: Linux
18+
strategy:
19+
matrix:
20+
arch: [aarch64, x86_64]
21+
runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
- name: Cache built binaries
26+
id: cache
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
_build
31+
_git
32+
_install
33+
key: ${{ github.job }}-${{ matrix.arch }}
34+
- name: Install dependencies
35+
if: steps.cache.outputs.cache-hit != 'true'
36+
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends
37+
yasm
38+
- name: Build binaries
39+
run: |
40+
if [ -d _install/host ]; then
41+
touch _install/host/*.stamp
42+
fi
43+
scripts/build-host -j "$(nproc)"
44+
- name: Upload artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: ${{ github.job }}-${{ matrix.arch }}
48+
path: _install/host
49+
if-no-files-found: error
50+
51+
android:
52+
needs: [linux]
53+
name: Android
54+
strategy:
55+
matrix:
56+
abi: [arm64-v8a, armeabi-v7a, x86_64, x86]
57+
runs-on: ubuntu-24.04
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
- name: Download host tools
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: linux-x86_64
65+
path: _install/host
66+
- name: Cache built binaries
67+
id: cache
68+
uses: actions/cache@v4
69+
with:
70+
path: |
71+
_git
72+
_install
73+
key: ${{ github.job }}-${{ matrix.abi }}
74+
- name: Install dependencies
75+
if: steps.cache.outputs.cache-hit != 'true'
76+
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends
77+
yasm
78+
- name: Build Android JNI
79+
run: scripts/build-android.sh ${{ matrix.abi }} -j "$(nproc)"
80+
81+
macos:
82+
name: macOS
83+
strategy:
84+
matrix:
85+
arch: [arm64, x86_64]
86+
runs-on: ${{ matrix.arch == 'x86_64' && 'macos-13' || 'macos-14' }}
87+
steps:
88+
- name: Checkout code
89+
uses: actions/checkout@v4
90+
- name: Cache built binaries
91+
id: cache
92+
uses: actions/cache@v4
93+
with:
94+
path: |
95+
_build
96+
_git
97+
_install
98+
key: ${{ github.job }}-${{ matrix.arch }}
99+
- name: Install dependencies
100+
if: steps.cache.outputs.cache-hit != 'true'
101+
run: brew install autoconf automake libtool yasm
102+
- name: Build binaries
103+
run: scripts/build-host -j "$(sysctl -n hw.logicalcpu)"
104+
- name: Upload artifact
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: ${{ github.job }}-${{ matrix.arch }}
108+
path: _install/host
109+
if-no-files-found: error

scripts/android.mk

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ export PKG_CONFIG_PATH := $(PREFIX)/lib/pkgconfig
1515
export PATH := $(TOOLCHAIN)/bin:$(PATH)
1616
export TOX4J_PLATFORM := $(TARGET)
1717

18-
protobuf_CONFIGURE := --prefix=$(PREFIX) --host=$(TARGET) --with-sysroot=$(SYSROOT) --disable-shared --with-protoc=$(PROTOC)
18+
protobuf_CONFIGURE := -D CMAKE_INSTALL_PREFIX:PATH=$(PREFIX) -D CMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE) -D BUILD_SHARED_LIBS=OFF -D WITH_PROTOC=$(PROTOC)
1919
libsodium_CONFIGURE := --prefix=$(PREFIX) --host=$(TARGET) --with-sysroot=$(SYSROOT) --disable-shared
2020
opus_CONFIGURE := --prefix=$(PREFIX) --host=$(TARGET) --with-sysroot=$(SYSROOT) --disable-shared
2121
libvpx_CONFIGURE := --prefix=$(PREFIX) --sdk-path=$(NDK_HOME) --libc=$(SYSROOT) --target=$(VPX_ARCH) --disable-examples --disable-unit-tests --enable-pic
22-
toxcore_CONFIGURE := -DCMAKE_INSTALL_PREFIX:PATH=$(PREFIX) -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE) -DANDROID_CPU_FEATURES=$(NDK_HOME)/sources/android/cpufeatures/cpu-features.c -DENABLE_STATIC=ON -DENABLE_SHARED=OFF
23-
tox4j_CONFIGURE := -DCMAKE_INSTALL_PREFIX:PATH=$(PREFIX) -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE) -DANDROID_CPU_FEATURES=$(NDK_HOME)/sources/android/cpufeatures/cpu-features.c
22+
toxcore_CONFIGURE := -D CMAKE_INSTALL_PREFIX:PATH=$(PREFIX) -D CMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE) -D ANDROID_CPU_FEATURES=$(NDK_HOME)/sources/android/cpufeatures/cpu-features.c -D ENABLE_STATIC=ON -D ENABLE_SHARED=OFF
23+
tox4j_CONFIGURE := -D CMAKE_INSTALL_PREFIX:PATH=$(PREFIX) -D CMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE) -D ANDROID_CPU_FEATURES=$(NDK_HOME)/sources/android/cpufeatures/cpu-features.c
2424

2525
build: $(PREFIX)/tox4j.stamp
2626

@@ -31,10 +31,9 @@ $(NDK_HOME):
3131
@$(PRE_RULE)
3232
@mkdir -p $(@D)
3333
# This is put into the root dir, not into $(SRCDIR), because it's huge and
34-
# clutters the Travis CI cache.
34+
# clutters the CI cache.
3535
test -f $(NDK_PACKAGE) || curl -s $(NDK_URL) -o $(NDK_PACKAGE)
36-
7z x $(NDK_PACKAGE) $(foreach x,$(NDK_FILES),'-ir!$(NDK_DIR)/$x')
37-
test -d $@ && find $@ -exec chmod +w {} \; && rm -rf $@
36+
$(SEVEN_ZIP) x $(NDK_PACKAGE)
3837
mv $(NDK_DIR) $@
3938
mkdir -p $(TOOLCHAIN)/bin
4039
ln -f $(CC) $(TOOLCHAIN)/bin/$(TARGET)-gcc

scripts/build-aarch64-linux-android

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ TARGET := aarch64-linux-android
44

55
include scripts/common.mk
66

7-
NDK_FILES := $(NDK_COMMON_FILES) \
8-
platforms/android-21/arch-arm64 \
9-
toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android \
10-
toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-* \
11-
toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-* \
12-
toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/21
13-
147
NDK_API := 21
158
NDK_ARCH := arm64
169
VPX_ARCH := arm64-android-gcc

scripts/build-android.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux -o pipefail
4+
5+
GIT_ROOT=$(git rev-parse --show-toplevel)
6+
cd "$GIT_ROOT"
7+
8+
ABI=$1
9+
10+
case $ABI in
11+
arm64-v8a)
12+
SCRIPT_ARCH=aarch64-linux-android
13+
;;
14+
armeabi-v7a)
15+
SCRIPT_ARCH=arm-linux-androideabi
16+
;;
17+
x86)
18+
SCRIPT_ARCH=i686-linux-android
19+
;;
20+
x86_64)
21+
SCRIPT_ARCH=x86_64-linux-android
22+
;;
23+
*)
24+
echo "Unknown ABI: $ABI"
25+
exit 1
26+
;;
27+
esac
28+
29+
"scripts/build-$SCRIPT_ARCH"

scripts/build-arm-linux-androideabi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ TARGET := arm-linux-androideabi
44

55
include scripts/common.mk
66

7-
NDK_FILES := $(NDK_COMMON_FILES) \
8-
platforms/android-9 \
9-
sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi* \
10-
toolchains/arm-linux-androideabi-4.9
11-
12-
NDK_API := 9
7+
NDK_API := 16
138
NDK_ARCH := arm
149
VPX_ARCH := armv7-android-gcc
1510

scripts/build-host

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ TOOLCHAIN := $(DESTDIR)/$(TARGET)
99
TOOLCHAIN_FILE := $(TOOLCHAIN)/.stamp
1010
PREFIX := $(TOOLCHAIN)
1111

12-
export CC := $(shell which clang || which gcc)
13-
export CXX := $(shell which clang++ || which g++)
14-
export PKG_CONFIG_PATH := $(PREFIX)/lib/pkgconfig
15-
export TOX4J_PLATFORM := $(shell perl -e 'print $$^O')-$(shell uname -m)
16-
export LD_LIBRARY_PATH := $(PREFIX)/lib
12+
export CC := $(shell which clang || which gcc)
13+
export CXX := $(shell which clang++ || which g++)
14+
export PKG_CONFIG_PATH := $(PREFIX)/lib/pkgconfig
15+
export TOX4J_PLATFORM := $(shell perl -e 'print $$^O')-$(shell uname -m)
16+
export LD_LIBRARY_PATH := $(PREFIX)/lib
17+
export DYLD_LIBRARY_PATH := $(PREFIX)/lib
1718

1819
build: $(PREFIX)/tox4j.stamp
1920
./gradlew build

scripts/build-i686-linux-android

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ TARGET := i686-linux-android
44

55
include scripts/common.mk
66

7-
NDK_FILES := $(NDK_COMMON_FILES) \
8-
platforms/android-9 \
9-
sources/cxx-stl/gnu-libstdc++/4.9/libs/x86 \
10-
toolchains/x86-4.9
11-
12-
NDK_API := 9
7+
NDK_API := 16
138
NDK_ARCH := x86
149
VPX_ARCH := x86-android-gcc
1510

scripts/build-x86_64-linux-android

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ TARGET := x86_64-linux-android
44

55
include scripts/common.mk
66

7-
NDK_FILES := $(NDK_COMMON_FILES) \
8-
platforms/android-21 \
9-
sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64 \
10-
toolchains/x86_64-4.9
11-
127
NDK_API := 21
138
NDK_ARCH := x86_64
149
VPX_ARCH := x86_64-android-gcc

scripts/common.mk

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ DESTDIR := $(CURDIR)/_install
33
BUILDDIR := $(CURDIR)/_build/$(TARGET)
44

55
export CFLAGS := -O3 -pipe
6-
export CXXFLAGS := -O3 -pipe
6+
export CXXFLAGS := -O3 -pipe -std=c++20
77
export LDFLAGS :=
88

99
export PATH := $(DESTDIR)/host/bin:$(PATH)
1010

1111
# Android NDK
12-
NDK_DIR := android-ndk-r21
13-
NDK_PACKAGE := $(NDK_DIR)-$(shell perl -e 'print $$^O')-x86_64.zip
12+
NDK_DIR := android-ndk-r27c
13+
ifeq ($(shell uname -s),Darwin)
14+
NDK_PACKAGE := $(NDK_DIR)-darwin.dmg
15+
SEVEN_ZIP := 7zz
16+
else
17+
NDK_PACKAGE := $(NDK_DIR)-linux.zip
18+
SEVEN_ZIP := 7z
19+
endif
1420
NDK_URL := http://dl.google.com/android/repository/$(NDK_PACKAGE)
15-
16-
NDK_COMMON_FILES := \
17-
sources/android/cpufeatures \
18-
toolchains/llvm/prebuilt/linux-x86_64/bin/clang \
19-
toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ \
20-
toolchains/llvm/prebuilt/linux-x86_64/lib/lib64 \
21-
toolchains/llvm/prebuilt/linux-x86_64/lib64 \
22-
toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include

0 commit comments

Comments
 (0)