forked from PojavLauncherTeam/lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
The Judge
committed
Nov 24, 2024
1 parent
d35e069
commit 19d4c36
Showing
1 changed file
with
141 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,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 |