forked from PojavLauncherTeam/lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_build_android.bash
137 lines (121 loc) · 4.38 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
set -e
export LIBFFI_VERSION=3.4.6
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/{freetype,glfw}
touch bin/libs/native/linux/x86/org/lwjgl/{freetype/libfreetype.so,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
if [ "$SKIP_FREETYPE" != "1" ]; then
#!/bin/bash
export BUILD_FREETYPE_VERSION=2.13.2
wget https://downloads.sourceforge.net/project/freetype/freetype2/$BUILD_FREETYPE_VERSION/freetype-$BUILD_FREETYPE_VERSION.tar.gz
tar xf freetype-$BUILD_FREETYPE_VERSION.tar.gz
rm freetype-$BUILD_FREETYPE_VERSION.tar.gz
cd freetype-$BUILD_FREETYPE_VERSION
export CC=$NDK_TARGET-linux-android${NDK_SUFFIX}21-clang
./configure \
--host=$TARGET \
--prefix=`pwd`/build_android-$LWJGL_BUILD_ARCH \
--without-zlib \
--with-brotli=no \
--with-bzip2=no \
--with-png=no \
--with-harfbuzz=no \
--enable-static=no \
--enable-shared=yes
make -j4
make install
llvm-strip ./build_android-$LWJGL_BUILD_ARCH/lib/libfreetype.so
cd ..
cp freetype-$BUILD_FREETYPE_VERSION/build_android-$LWJGL_BUILD_ARCH/lib/libfreetype.so $LWJGL_NATIVE/
rm -rf freetype-$BUILD_FREETYPE_VERSION
unset BUILD_FREETYPE_VERSION
unset CC
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://github.com/PojavLauncherTeam/shaderc/releases/download/v2024.2-pojav/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=true \
-Dbinding.fmod=false \
-Dbinding.harfbuzz=false \
-Dbinding.hwloc=false \
-Dbinding.jawt=false \
-Dbinding.jemalloc=false \
-Dbinding.ktx=false \
-Dbinding.libdivide=false \
-Dbinding.llvm=false \
-Dbinding.lmdb=true \
-Dbinding.lz4=false \
-Dbinding.meow=false \
-Dbinding.meshoptimizer=false \
-Dbinding.nfd=false \
-Dbinding.nuklear=false \
-Dbinding.odbc=false \
-Dbinding.opencl=false \
-Dbinding.openvr=true \
-Dbinding.openxr=true \
-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.3 \
-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/
if [ -e "$LWJGL_NATIVE/libfreetype.so" ]; then
cp $LWJGL_NATIVE/libfreetype.so bin/out/
fi
# Cleanup unused output jar files
find bin/RELEASE \( -name '*-natives-*' -o -name '*-sources.jar' \) -delete