mirror of
https://github.com/ApfelTeeSaft/OpenRoyale.git
synced 2026-08-26 19:33:32 +00:00
24 lines
1.3 KiB
Bash
24 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
# verify_native_host.sh - host-compile the reconstructed native skeleton WITHOUT the Android NDK.
|
|
# Compiles native/src/libg/** into a host shared object using the JDK's jni.h, purely to syntax/
|
|
# type-check the JNI boundary + engine interface in an environment where the NDK is unavailable.
|
|
# It does NOT produce an Android .so.
|
|
set -euo pipefail
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJ="$(cd "$HERE/../.." && pwd)"
|
|
JH="${JAVA_HOME:-$(dirname "$(dirname "$(readlink -f "$(command -v javac)")")")}"
|
|
[ -f "$JH/include/jni.h" ] || { echo "jni.h not found under JAVA_HOME=$JH"; exit 2; }
|
|
|
|
CXX="${CXX:-g++}"
|
|
OUT="$(mktemp -d)"; trap 'rm -rf "$OUT"' EXIT
|
|
mapfile -t SRCS < <(find "$PROJ/native/src/libg" -name '*.cpp')
|
|
echo "[*] Host-compiling ${#SRCS[@]} native source(s) with $CXX (jni.h from $JH)"
|
|
"$CXX" -std=c++17 -fPIC -shared -O0 -Wall -Wextra \
|
|
-I"$PROJ/native/include" -I"$PROJ/native/third_party/fmod/include" -I"$JH/include" -I"$JH/include/linux" \
|
|
"${SRCS[@]}" -o "$OUT/libg_host.so"
|
|
echo "[+] NATIVE HOST COMPILE OK -> libg_host.so"
|
|
echo " JNI exports present:"
|
|
nm -D --defined-only "$OUT/libg_host.so" 2>/dev/null | grep -cE "Java_com_supercell_titan_|JNI_OnLoad" \
|
|
| sed 's/^/ Java_com_supercell_titan_* + JNI_OnLoad = /'
|
|
echo " (expected 61: 60 JNI methods + JNI_OnLoad)"
|