build with NDK toolchains #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build with NDK toolchains | |
on: | |
workflow_dispatch: | |
env: | |
api_version: 28 # min. 21 | |
ndk: r26d # android-ndk-$ndk-linux.zip | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout zerotier-magisk | |
uses: actions/checkout@v4 | |
- name: Checkout ZeroTierOne | |
uses: actions/checkout@v4 | |
with: | |
repository: zerotier/ZeroTierOne | |
path: ZeroTierOne | |
- name: Checkout libnatpmp | |
uses: actions/checkout@v4 | |
with: | |
repository: miniupnp/libnatpmp | |
path: libnatpmp | |
- id: commit | |
uses: prompt/actions-commit-hash@v3 | |
- name: Prepare NDK Toolchain | |
run: | | |
wget -qO ndk.zip https://dl.google.com/android/repository/android-ndk-$ndk-linux.zip | |
unzip -qq ndk.zip "android-ndk-$ndk/toolchains/*" && rm ndk.zip -f | |
- name: Patch ZeroTier for Cross-Compile | |
run: | | |
pip3 install toml | |
python3 build/patch.py | |
- name: Build for AArch64 | |
run: | | |
PATH=`pwd`/android-ndk-$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH | |
NDK_ROOT=`pwd`/android-ndk-$ndk/toolchains/llvm/prebuilt/linux-x86_64 | |
CC=aarch64-linux-android$api_version-clang | |
CXX=aarch64-linux-android$api_version-clang++ | |
cd libnatpmp | |
make clean | |
make --silent CC=$CC natpmpc-shared | |
cd .. | |
cd ZeroTierOne | |
make clean | |
make --silent -j $(nproc) ZT_DEBUG=0 ZT_SSO_SUPPORTED=0 CC=$CC CXX=$CXX LDFLAGS="-L../libnatpmp" DEFS="-I../libnatpmp -D__GLIBC__=0" | |
cd .. | |
mkdir -p magisk/zerotier/lib | |
cp ZeroTierOne/zerotier-one magisk/zerotier | |
cp $NDK_ROOT/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so magisk/zerotier/lib | |
- name: Upload AArch64 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: zerotier-magisk-aarch64-ndk-${{ steps.commit.outputs.short }} | |
path: magisk/ | |
- name: Build for Arm | |
run: | | |
PATH=`pwd`/android-ndk-$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH | |
NDK_ROOT=`pwd`/android-ndk-$ndk/toolchains/llvm/prebuilt/linux-x86_64 | |
CC=armv7a-linux-androideabi$api_version-clang | |
CXX=armv7a-linux-androideabi$api_version-clang++ | |
cd libnatpmp | |
make clean | |
make CC=$CC natpmpc-shared | |
cd .. | |
cd ZeroTierOne | |
mv make-linux.mk.arm.ndk make-linux.mk | |
make clean | |
make --silent -j $(nproc) ZT_DEBUG=0 ZT_SSO_SUPPORTED=0 CC=$CC CXX=$CXX LDFLAGS="-L../libnatpmp" DEFS="-I../libnatpmp -D__GLIBC__=0" | |
cd .. | |
cp ZeroTierOne/zerotier-one magisk/zerotier/ | |
cp $NDK_ROOT/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so magisk/zerotier/lib | |
- name: Upload Arm | |
uses: actions/upload-artifact@v4 | |
with: | |
name: zerotier-magisk-arm-ndk-${{ steps.commit.outputs.short }} | |
path: magisk/ |