-
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add GitHubActions to build for android
Signed-off-by: leleliu008 <leleliu008@gmail.com>
- Loading branch information
1 parent
70704c7
commit 5d66b54
Showing
1 changed file
with
115 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
name: cross compile with android-ndk | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
cross-compile-for-android: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11] | ||
target-abi: [armeabi-v7a, arm64-v8a, x86, x86_64] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- run: brew install tree file | ||
|
||
- run: tree --version | ||
- run: file --version | ||
- run: make --version | ||
|
||
- run: echo "ANDROID_NDK_HOME=${ANDROID_NDK_LATEST_HOME}" >> "$GITHUB_ENV" | ||
|
||
- run: | | ||
env | sed -n '/^ANDROID_/p' | ||
- run: cat "$ANDROID_NDK_HOME/source.properties" | ||
|
||
- name: install runtime dependencies | ||
run: | | ||
for item in tbb-2021.5.0-bin xxhash-0.8.1-bin openssl-1.1.1g-bin | ||
do | ||
curl -LO https://github.com/leleliu008/test/releases/download/20220103-1623/${item}.tar.xz | ||
tar vxf ${item}.tar.xz | ||
printf '%s\n' "$item" >> runtime-dependencies | ||
done | ||
- name: build for ${{ matrix.target-abi }} | ||
run: | | ||
COLOR_GREEN='\033[0;32m' # Green | ||
COLOR_PURPLE='\033[0;35m' # Purple | ||
COLOR_OFF='\033[0m' # Reset | ||
run() { | ||
printf '%b\n' "$COLOR_PURPLE==>$COLOR_OFF $COLOR_GREEN$*$COLOR_OFF" | ||
eval "$*" | ||
} | ||
BUILD_MACHINE_OS_TYPE=$(uname | tr A-Z a-z) | ||
BUILD_MACHINE_OS_ARCH=$(uname -m) | ||
ANDROID_NDK_BASE=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$BUILD_MACHINE_OS_TYPE-$BUILD_MACHINE_OS_ARCH | ||
ANDROID_NDK_BIND=$ANDROID_NDK_BASE/bin | ||
SYSROOT=$ANDROID_NDK_BASE/sysroot | ||
export PATH="$ANDROID_NDK_BIND:$PATH" | ||
export CPPFLAGS="--sysroot $SYSROOT" | ||
export CXXFLAGS="--sysroot $SYSROOT" | ||
export CFLAGS="--sysroot $SYSROOT" | ||
export LDFLAGS="--sysroot $SYSROOT" | ||
for item in $(cat runtime-dependencies) | ||
do | ||
export CPPFLAGS="$CPPFLAGS -I$PWD/${item}/${{ matrix.target-abi }}/include" | ||
export LDFLAGS="$LDFLAGS -L$PWD/${item}/${{ matrix.target-abi }}/lib" | ||
done | ||
case ${{ matrix.target-abi }} in | ||
armeabi-v7a) export CC=armv7a-linux-androideabi21-clang ;; | ||
arm64-v8a) export CC=aarch64-linux-android21-clang ;; | ||
x86) export CC=i686-linux-android21-clang ;; | ||
x86_64) export CC=x86_64-linux-android21-clang ;; | ||
esac | ||
export CXX=${CC}++ | ||
export AR=llvm-ar | ||
export STRIP=llvm-strip | ||
printf '%b\n' "$COLOR_PURPLE==>$COLOR_OFF ${COLOR_GREEN}show PATH$COLOR_OFF" | ||
printf '%s\n' "$PATH" | tr ':' '\n' | ||
printf '%s\n' | ||
# avoid link against librt | ||
printf 'INPUT(-lc)\n' > librt.a | ||
export LDFLAGS="$LDFLAGS -L$PWD" | ||
run make clean | ||
run make install PREFIX=$PWD/install.d OS=Linux LTO=1 SYSTEM_TBB=1 SYSTEM_XXHASH=1 | ||
- run: tree install.d | ||
|
||
- run: | | ||
file install.d/lib/mold/mold-wrapper.so | ||
case ${{ matrix.target-abi }} in | ||
armeabi-v7a) file install.d/lib/mold/mold-wrapper.so | grep 'ELF 32-bit LSB shared object, ARM, EABI5' ;; | ||
arm64-v8a) file install.d/lib/mold/mold-wrapper.so | grep 'ELF 64-bit LSB shared object, ARM aarch64,' ;; | ||
x86) file install.d/lib/mold/mold-wrapper.so | grep 'ELF 32-bit LSB shared object, Intel 80386,' ;; | ||
x86_64) file install.d/lib/mold/mold-wrapper.so | grep 'ELF 64-bit LSB shared object, x86-64,' ;; | ||
esac | ||
- run: | | ||
file install.d/bin/mold | ||
case ${{ matrix.target-abi }} in | ||
armeabi-v7a) file install.d/bin/mold | grep 'ELF 32-bit LSB pie executable, ARM, EABI5' ;; | ||
arm64-v8a) file install.d/bin/mold | grep 'ELF 64-bit LSB pie executable, ARM aarch64,' ;; | ||
x86) file install.d/bin/mold | grep 'ELF 32-bit LSB pie executable, Intel 80386,' ;; | ||
x86_64) file install.d/bin/mold | grep 'ELF 64-bit LSB pie executable, x86-64,' ;; | ||
esac |