From 2e2c3f8a354a95de99eb085fd5dfd24b63ba01db Mon Sep 17 00:00:00 2001 From: Tom Rothamel Date: Sun, 22 Dec 2024 01:36:50 -0500 Subject: [PATCH] Build with Android ndk r27c. This required fixing an issuew with SDL sensor events using a removed API. --- patches/SDL2-2.0.20/android-alooper-fix.diff | 44 ++++++++++++++++++++ patches/SDL2-2.0.20/series | 1 + renpybuild/run.py | 4 +- tars/.gitignore | 4 +- tars/README.rst | 2 +- 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 patches/SDL2-2.0.20/android-alooper-fix.diff diff --git a/patches/SDL2-2.0.20/android-alooper-fix.diff b/patches/SDL2-2.0.20/android-alooper-fix.diff new file mode 100644 index 00000000..913a47b4 --- /dev/null +++ b/patches/SDL2-2.0.20/android-alooper-fix.diff @@ -0,0 +1,44 @@ +Backport ALooper_poolAll fix. + +From: Tom Rothamel + +From https://github.com/libsdl-org/SDL/pull/9807 +--- + src/sensor/android/SDL_androidsensor.c | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c +index e6cfc23..d4179bf 100644 +--- a/src/sensor/android/SDL_androidsensor.c ++++ b/src/sensor/android/SDL_androidsensor.c +@@ -163,7 +163,7 @@ SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index) + sensor->hwdata = hwdata; + return 0; + } +- ++ + static void + SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor) + { +@@ -171,10 +171,17 @@ SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor) + ASensorEvent event; + struct android_poll_source* source; + +- if (ALooper_pollAll(0, NULL, &events, (void**)&source) == LOOPER_ID_USER) { +- SDL_zero(event); +- while (ASensorEventQueue_getEvents(sensor->hwdata->eventqueue, &event, 1) > 0) { +- SDL_PrivateSensorUpdate(sensor, event.data, SDL_arraysize(event.data)); ++ while (1) { ++ int result = ALooper_pollOnce(0, NULL, &events, (void**)&source); ++ if (result == LOOPER_ID_USER) { ++ SDL_zero(event); ++ while (ASensorEventQueue_getEvents(sensor->hwdata->eventqueue, &event, 1) > 0) { ++ SDL_PrivateSensorUpdate(sensor, event.data, SDL_arraysize(event.data)); ++ } ++ } ++ ++ if (result <0) { ++ break; + } + } + } diff --git a/patches/SDL2-2.0.20/series b/patches/SDL2-2.0.20/series index 55e78e07..748515c2 100644 --- a/patches/SDL2-2.0.20/series +++ b/patches/SDL2-2.0.20/series @@ -12,3 +12,4 @@ declaration-after-statement.diff android-no-multi-window.diff x11-numlock-capslock-scrolllock.diff x11-ime.diff +android-alooper-fix.diff diff --git a/renpybuild/run.py b/renpybuild/run.py index d0e4f9b9..f6340588 100644 --- a/renpybuild/run.py +++ b/renpybuild/run.py @@ -104,7 +104,7 @@ def build_environment(c): emsdk_environment(c) if c.platform == "android": - c.var("ndk_version", "android-ndk-r25c") + c.var("ndk_version", "android-ndk-r27c") cpuccount = os.cpu_count() @@ -259,6 +259,7 @@ def build_environment(c): android_llvm(c, "x86_64") c.env("CFLAGS", "{{ CFLAGS }} -DSDL_MAIN_HANDLED") + c.env("LDFLAGS", "{{ LDFLAGS }} -Wl,-z,max-page-size=16384") c.var("cmake_system_name", "Android") c.var("cmake_system_processor", "x86_64") @@ -270,6 +271,7 @@ def build_environment(c): android_llvm(c, "aarch64") c.env("CFLAGS", "{{ CFLAGS }} -DSDL_MAIN_HANDLED") + c.env("LDFLAGS", "{{ LDFLAGS }} -Wl,-z,max-page-size=16384") c.var("cmake_system_name", "Android") c.var("cmake_system_processor", "aarch64") diff --git a/tars/.gitignore b/tars/.gitignore index cd4fcdd6..87fa4ef5 100644 --- a/tars/.gitignore +++ b/tars/.gitignore @@ -1,10 +1,10 @@ old/ -android-ndk-r25c-linux.zip +android-ndk-r27c-linux.zip CubismSdkForNative-4-r.6.2.zip iPhoneOS14.0.sdk.tar.gz iPhoneSimulator14.0.sdk.tar.gz -llvm-mingw-20220906-ucrt-ubuntu-18.04-x86_64.tar.xz +llvm-mingw-* MacOSX10.10.sdk.tar.bz2 MacOSX12.3.sdk.tar.bz2 steamworks_sdk_160.zip diff --git a/tars/README.rst b/tars/README.rst index 4f9fb208..ca5ba64b 100644 --- a/tars/README.rst +++ b/tars/README.rst @@ -21,7 +21,7 @@ Run ./ios_toolchains.sh /path/to/Xcode.app Android NDK ----------- -* android-ndk-r25c-linux.zip +* android-ndk-r27c-linux.zip Downloaded from https://developer.android.com/ndk/downloads .