mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
Android: Output sys_message/sys_error to android log
This commit is contained in:
@@ -45,6 +45,7 @@ elseif (ANDROID)
|
||||
set(SDL2TTF_FOUND 1)
|
||||
set(DEFAULT_FONT_PATH .)
|
||||
find_library(ndk_zlib z)
|
||||
find_library(ndk_log log)
|
||||
else()
|
||||
include(TestBigEndian)
|
||||
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ if (EMSCRIPTEN)
|
||||
|
||||
elseif (ANDROID)
|
||||
|
||||
target_link_libraries(xsystem35 PRIVATE SDL2 SDL2_ttf SDL2_mixer ${ndk_zlib})
|
||||
target_link_libraries(xsystem35 PRIVATE SDL2 SDL2_ttf SDL2_mixer ${ndk_zlib} ${ndk_log})
|
||||
|
||||
else() # non-emscripten, non-android
|
||||
target_link_libraries(xsystem35 PRIVATE m ZLIB::ZLIB)
|
||||
|
||||
+30
-13
@@ -49,6 +49,10 @@
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
#include "nact.h"
|
||||
#include "portab.h"
|
||||
#include "xsystem35.h"
|
||||
@@ -192,32 +196,45 @@ static void sys35_usage(boolean verbose) {
|
||||
}
|
||||
|
||||
void sys_message(char *format, ...) {
|
||||
if (debuglv < sys_nextdebuglv)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
#ifdef DEBUG
|
||||
if (debuglv >= sys_nextdebuglv) {
|
||||
if (sys_nextdebuglv >= 5) {
|
||||
vfprintf(fpdebuglog, format, args);
|
||||
fflush(fpdebuglog);
|
||||
} else {
|
||||
vfprintf(stderr, format, args);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (debuglv >= sys_nextdebuglv) {
|
||||
|
||||
#ifdef __ANDROID__
|
||||
const int prio_table[] = {
|
||||
ANDROID_LOG_FATAL,
|
||||
ANDROID_LOG_ERROR,
|
||||
ANDROID_LOG_WARN,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_VERBOSE,
|
||||
};
|
||||
int prio = prio_table[min(sys_nextdebuglv, 5)];
|
||||
__android_log_vprint(prio, "xsystem35", format, args);
|
||||
#elif defined (DEBUG)
|
||||
if (sys_nextdebuglv >= 5) {
|
||||
vfprintf(fpdebuglog, format, args);
|
||||
fflush(fpdebuglog);
|
||||
} else {
|
||||
vfprintf(stderr, format, args);
|
||||
}
|
||||
#else
|
||||
vfprintf(stderr, format, args);
|
||||
#endif
|
||||
va_end(args);
|
||||
|
||||
}
|
||||
|
||||
void sys_error(char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
#ifdef __ANDROID__
|
||||
__android_log_vprint(ANDROID_LOG_FATAL, "xsystem35", format, args);
|
||||
#else
|
||||
vfprintf(stderr, format, args);
|
||||
#endif
|
||||
va_end(args);
|
||||
sys35_remove();
|
||||
exit(1);
|
||||
|
||||
Reference in New Issue
Block a user