From f922ffe997ed3de0ea8c509b57c37f7adb14efed Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Fri, 2 Nov 2018 06:07:49 +0100 Subject: [PATCH] android: log into logcat --- src/CMakeLists.txt | 4 ++++ src/utils.c | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6a2694..4c18104 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,4 +26,8 @@ SET_TARGET_PROPERTIES("libsuperderpy" PROPERTIES PREFIX "") target_link_libraries("libsuperderpy" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_VIDEO_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} m dl) +if (ANDROID) + target_link_libraries("libsuperderpy" log) +endif (ANDROID) + install(TARGETS "libsuperderpy" DESTINATION ${LIB_INSTALL_DIR}) diff --git a/src/utils.c b/src/utils.c index 33c50bb..8580ad8 100644 --- a/src/utils.c +++ b/src/utils.c @@ -26,6 +26,9 @@ #include #include #include +#ifdef ALLEGRO_ANDROID +#include +#endif // TODO: split to separate files @@ -397,7 +400,7 @@ __attribute__((__format__(__printf__, 5, 0))) SYMBOL_EXPORT void PrintConsoleWit ALLEGRO_DEBUG("%s\n", text); SUPPRESS_END -#ifndef __EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) && !defined(ALLEGRO_ANDROID) if (game->config.debug) #endif { @@ -405,6 +408,9 @@ __attribute__((__format__(__printf__, 5, 0))) SYMBOL_EXPORT void PrintConsoleWit printf("%s:%d ", file, line); } printf("[%s] %s\n", func, text); +#ifdef ALLEGRO_ANDROID + __android_log_print(ANDROID_LOG_DEBUG, al_get_app_name(), "[%s] %s", func, text); +#endif fflush(stdout); } game->_priv.console_pos++;