Do not build libsdl_main.so for SDL2

This commit is contained in:
Sergii Pylypenko
2022-01-03 00:28:09 +02:00
parent 4cdad6573b
commit ef8b1d2c7d
4 changed files with 10 additions and 60 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1,46 +0,0 @@
#include "SDL_config.h"
#ifdef __ANDROID__
/* Include the SDL main definition header */
#include "SDL_main.h"
#include <android/log.h>
/*******************************************************************************
Functions called by JNI
*******************************************************************************/
#include <jni.h>
// 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: */

View File

@@ -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
};