forked from LWJGL/lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 11
/
ci_build_android.bash
98 lines (87 loc) · 3.2 KB
/
ci_build_android.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
set -e
export LIBFFI_VERSION=3.4.2
export ANDROID=1 LWJGL_BUILD_OFFLINE=1
#export LWJGL_BUILD_ARCH=arm64
# Setup env
if [ "$LWJGL_BUILD_ARCH" == "arm64" ]; then
export NDK_ABI=arm64-v8a NDK_TARGET=aarch64
elif [ "$LWJGL_BUILD_ARCH" == "arm32" ]; then
export NDK_ABI=armeabi-v7a NDK_TARGET=armv7a NDK_SUFFIX=eabi
elif [ "$LWJGL_BUILD_ARCH" == "x86" ]; then
export NDK_ABI=x86 NDK_TARGET=i686
# Workaround: LWJGL 3 lacks of x86 Linux libraries
mkdir -p bin/libs/native/linux/x86/org/lwjgl/glfw
touch bin/libs/native/linux/x86/org/lwjgl/glfw/libglfw.so
elif [ "$LWJGL_BUILD_ARCH" == "x64" ]; then
export NDK_ABI=x86_64 NDK_TARGET=x86_64
fi
export TARGET=$NDK_TARGET-linux-android$NDK_SUFFIX
export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin
LWJGL_NATIVE=bin/libs/native/linux/$LWJGL_BUILD_ARCH/org/lwjgl
mkdir -p $LWJGL_NATIVE
if [ "$SKIP_LIBFFI" != "1" ]; then
# Get libffi
if [ ! -d libffi ]; then
wget https://github.com/libffi/libffi/releases/download/v$LIBFFI_VERSION/libffi-$LIBFFI_VERSION.tar.gz
tar xvf libffi-$LIBFFI_VERSION.tar.gz
mv libffi-$LIBFFI_VERSION libffi
fi
cd libffi
# Build libffi
bash configure --host=$TARGET --prefix=$PWD/$NDK_TARGET-unknown-linux-android$NDK_SUFFIX CC=${TARGET}21-clang CXX=${TARGET}21-clang++
make -j4
cd ..
# Copy libffi
cp libffi/$NDK_TARGET-linux-android$NDK_SUFFIX/.libs/libffi.a $LWJGL_NATIVE/
fi
# Download libraries
POJAV_NATIVES="https://github.com/PojavLauncherTeam/PojavLauncher/raw/v3_openjdk/app_pojavlauncher/src/main/jniLibs/$NDK_ABI"
wget -nc $POJAV_NATIVES/libopenal.so -P $LWJGL_NATIVE/openal
wget -nc "https://nightly.link/PojavLauncherTeam/shaderc/workflows/android/main/libshaderc-$NDK_ABI.zip"
unzip -o libshaderc-$NDK_ABI.zip -d $LWJGL_NATIVE/shaderc
# HACK: Skip compiling and running the generator to save time and keep LWJGLX functions
mkdir -p bin/classes/{generator,templates/META-INF}
touch bin/classes/{generator,templates}/touch.txt bin/classes/generator/generated-touch.txt
# Build LWJGL 3
ant -version
yes | ant -Dplatform.linux=true \
-Dbinding.assimp=false \
-Dbinding.bgfx=false \
-Dbinding.cuda=false \
-Dbinding.egl=false \
-Dbinding.jawt=false \
-Dbinding.jemalloc=false \
-Dbinding.libdivide=false \
-Dbinding.llvm=false \
-Dbinding.lmdb=false \
-Dbinding.lz4=false \
-Dbinding.meow=false \
-Dbinding.meshoptimizer=false \
-Dbinding.nfd=false \
-Dbinding.nuklear=false \
-Dbinding.odbc=false \
-Dbinding.opencl=false \
-Dbinding.openvr=false \
-Dbinding.openxr=false \
-Dbinding.opus=false \
-Dbinding.par=false \
-Dbinding.remotery=false \
-Dbinding.rpmalloc=false \
-Dbinding.spvc=false \
-Dbinding.sse=false \
-Dbinding.tinyexr=false \
-Dbinding.tootle=false \
-Dbinding.xxhash=false \
-Dbinding.yoga=false \
-Dbinding.zstd=false \
-Dbuild.type=release/3.3.1 \
-Djavadoc.skip=true \
-Dnashorn.args="--no-deprecation-warning" \
compile compile-native release
# Copy native libraries
rm -rf bin/out; mkdir bin/out
find $LWJGL_NATIVE -name 'liblwjgl*.so' -exec cp {} bin/out/ \;
cp $LWJGL_NATIVE/shaderc/libshaderc.so bin/out/
# Cleanup unused output jar files
find bin/RELEASE \( -name '*-natives-*' -o -name '*-sources.jar' \) -delete