looper/setup-android-project.sh
Zachary Hall b7d04bec65
Some checks failed
Build / build-android (push) Waiting to run
Build / build-windows (push) Waiting to run
Build / build-appimage (push) Waiting to run
Build / build-gentoo (push) Successful in 1m5s
Build / get-source-code (push) Has been cancelled
Add source code bundle creation workflow
2024-10-20 15:12:03 -07:00

23 lines
1 KiB
Bash
Executable file

#!/bin/env -S NOT_SOURCED=1 /bin/bash
if ! [ "$NOT_SOURCED" = "1" ]; then
echo "Error: This script must not be sourced!" >&2
return 1
fi
get_abs_filename() {
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" | sed 's@/\./@/@g' | sed 's@/\.$@@g'
}
export PROJECT_DIR="$(get_abs_filename $(dirname "$0"))"
export ANDROID_PROJECT_DIR="${PROJECT_DIR}/sdl-android-project"
export ANDROID_APP_DIR="${ANDROID_PROJECT_DIR}/app"
export ANDROID_JNI_DIR="${ANDROID_APP_DIR}/jni"
echo "Project directory: $PROJECT_DIR"
echo "Android project directory: $ANDROID_PROJECT_DIR"
echo "Android JNI symlink: $ANDROID_JNI_DIR -> $PROJECT_DIR"
pushd "${PROJECT_DIR}"
[ -d "$ANDROID_JNI_DIR" ] && rm -rf "$ANDROID_JNI_DIR"
ln -sf "$PROJECT_DIR" "$ANDROID_JNI_DIR"
rm -rf "${ANDROID_APP_DIR}/src/main/java/org"
cp -r "${PROJECT_DIR}/subprojects/SDL/android-project/app/src/main/java/org" "${ANDROID_APP_DIR}/src/main/java/org"
patch -N "${ANDROID_APP_DIR}/src/main/java/org/libsdl/app/SDLActivity.java" -i "${PROJECT_DIR}/libnames.patch"
popd