From 19d4c36dc8af60b64ecf50d87bd2ec6300cf00d8 Mon Sep 17 00:00:00 2001 From: The Judge Date: Sun, 24 Nov 2024 14:50:51 -0800 Subject: [PATCH] Try again --- ci_build_android.bash | 141 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 ci_build_android.bash diff --git a/ci_build_android.bash b/ci_build_android.bash new file mode 100644 index 0000000000..de73d2aec0 --- /dev/null +++ b/ci_build_android.bash @@ -0,0 +1,141 @@ +#!/bin/bash +# +# Copyright LWJGL. All rights reserved. +# License terms: https://www.lwjgl.org/license +# +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 \ No newline at end of file