From ef8b1d2c7de3eb258f04b104cc8c2ba1adca353d Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Mon, 3 Jan 2022 00:28:09 +0200 Subject: [PATCH] Do not build libsdl_main.so for SDL2 --- project/jni/SettingsTemplate.mk | 6 +-- project/jni/sdl_main/Android.mk | 2 +- project/jni/sdl_main/SDL_android_main.cpp | 46 ----------------------- project/jni/sdl_main/sdl_main.c | 16 +++----- 4 files changed, 10 insertions(+), 60 deletions(-) delete mode 100644 project/jni/sdl_main/SDL_android_main.cpp diff --git a/project/jni/SettingsTemplate.mk b/project/jni/SettingsTemplate.mk index b149ebf59..d9f2490a5 100644 --- a/project/jni/SettingsTemplate.mk +++ b/project/jni/SettingsTemplate.mk @@ -1,4 +1,6 @@ +SDL_VERSION := 1.2 + # To filter out static libs from all libs in makefile APP_AVAILABLE_STATIC_LIBS := jpeg png freetype fontconfig xerces ogg vorbis flac \ boost_atomic boost_chrono boost_container boost_context boost_coroutine boost_date_time boost_exception boost_filesystem \ @@ -12,7 +14,7 @@ APP_AVAILABLE_STATIC_LIBS := jpeg png freetype fontconfig xerces ogg vorbis flac APP_MODULES := application sdl-1.2 sdl_native_helpers jpeg png ogg flac vorbis freetype tremor ogg ifeq ($(CUSTOM_BUILD_SCRIPT_FIRST_PASS),) -APP_MODULES += application sdl_main +APP_MODULES += application $(if $(filter 1.2, $(SDL_VERSION)), sdl_main) endif ifeq ($(APP_ABI),) @@ -62,8 +64,6 @@ USE_GL4ES := SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=LCTRL -DSDL_ANDROID_KEYCODE_1=LALT -DSDL_ANDROID_KEYCODE_2=SPACE -DSDL_ANDROID_KEYCODE_3=RETURN -DSDL_ANDROID_KEYCODE_4=RETURN -SDL_VERSION := 1.2 - NDK_TOOLCHAIN_VERSION := clang APP_PLATFORM := android-16 diff --git a/project/jni/sdl_main/Android.mk b/project/jni/sdl_main/Android.mk index 45790d145..adaf4b619 100644 --- a/project/jni/sdl_main/Android.mk +++ b/project/jni/sdl_main/Android.mk @@ -13,7 +13,7 @@ LOCAL_CFLAGS := -DSDL_JAVA_PACKAGE_PATH=$(SDL_JAVA_PACKAGE_PATH) -DSDL_CURDIR_PA LOCAL_CPP_EXTENSION := .cpp -LOCAL_SRC_FILES := sdl_main.c SDL_android_main.cpp +LOCAL_SRC_FILES := sdl_main.c LOCAL_SHARED_LIBRARIES := sdl-1.2 application LOCAL_LDLIBS := -llog diff --git a/project/jni/sdl_main/SDL_android_main.cpp b/project/jni/sdl_main/SDL_android_main.cpp deleted file mode 100644 index f9fae039e..000000000 --- a/project/jni/sdl_main/SDL_android_main.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -#include "SDL_config.h" - -#ifdef __ANDROID__ - -/* Include the SDL main definition header */ -#include "SDL_main.h" -#include - -/******************************************************************************* - Functions called by JNI -*******************************************************************************/ -#include - -// Called before SDL_main() to initialize JNI bindings in SDL library -extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls); - -// Library init -extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) -{ - return JNI_VERSION_1_6; -} - -// Start up the SDL app -extern "C" void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj) -{ - /* This interface could expand with ABI negotiation, calbacks, etc. */ - SDL_Android_Init(env, cls); - - - /* Run the application code! */ - int status; - char *argv[2]; - argv[0] = strdup("SDL_app"); - argv[1] = NULL; - __android_log_print(ANDROID_LOG_INFO, "libSDL", "Calling SDL_main(\"%s\")", argv[0]); - status = SDL_main(1, argv); - - /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */ - //exit(status); -} - -#endif /* __ANDROID__ */ - -/* vi: set ts=4 sw=4 expandtab: */ - diff --git a/project/jni/sdl_main/sdl_main.c b/project/jni/sdl_main/sdl_main.c index 735bd94de..05c7f7acf 100644 --- a/project/jni/sdl_main/sdl_main.c +++ b/project/jni/sdl_main/sdl_main.c @@ -8,10 +8,7 @@ #include "SDL_thread.h" #include "SDL_main.h" -#if SDL_VERSION_ATLEAST(2,0,0) -#else #include "SDL_android.h" -#endif /* JNI-C wrapper stuff */ @@ -35,6 +32,12 @@ static char ** argv = NULL; static JNIEnv* static_env = NULL; static jobject static_thiz = NULL; +// Library init +jint JNI_OnLoad(JavaVM* vm, void* reserved) +{ + return JNI_VERSION_1_6; +} + JNIEnv* SDL_ANDROID_JniEnv() { return static_env; @@ -44,8 +47,6 @@ jobject SDL_ANDROID_JniVideoObject() return static_thiz; } -#if SDL_VERSION_ATLEAST(1,3,0) -#else extern void SDL_ANDROID_MultiThreadedVideoLoopInit(); extern void SDL_ANDROID_MultiThreadedVideoLoop(); @@ -59,7 +60,6 @@ int threadedMain(void * unused) __android_log_print(ANDROID_LOG_INFO, "libSDL", "Application closed, calling exit(0)"); exit(0); } -#endif extern C_LINKAGE void JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring jcurdir, jstring cmdline, jint multiThreadedVideo, jint unused ) @@ -130,9 +130,6 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring for( i = 0; i < argc; i++ ) __android_log_print(ANDROID_LOG_INFO, "libSDL", "param %d = \"%s\"", i, argv[i]); -#if SDL_VERSION_ATLEAST(1,3,0) - SDL_main( argc, argv ); -#else if( ! multiThreadedVideo ) { SDL_main( argc, argv ); @@ -143,5 +140,4 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring SDL_CreateThread(threadedMain, NULL); SDL_ANDROID_MultiThreadedVideoLoop(); } -#endif };