From f9f7cbc1aa36cce6caa42c0cf58c5cbefedc19fd Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 3 Sep 2019 11:43:40 -0700 Subject: [PATCH] util: android logging support In particular, it would be nice for failed debug_assert() msgs to show up in logcat. Signed-off-by: Rob Clark Kristian H. Kristensen Reviewed-by: Eric Engestrom --- src/util/meson.build | 14 +++++++++++++- src/util/os_misc.c | 9 ++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/util/meson.build b/src/util/meson.build index cf1616e7bc6..3e65a36fdb5 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -134,11 +134,23 @@ format_srgb = custom_target( capture : true, ) +deps_for_libmesa_util = [ + dep_zlib, + dep_clock, + dep_thread, + dep_atomic, + dep_m, +] + +if with_platform_android + deps_for_libmesa_util += dep_android +endif + _libmesa_util = static_library( 'mesa_util', [files_mesa_util, format_srgb], include_directories : inc_common, - dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic, dep_m], + dependencies : deps_for_libmesa_util, c_args : [c_msvc_compat_args, c_vis_args], build_by_default : false ) diff --git a/src/util/os_misc.c b/src/util/os_misc.c index 436bc38604b..e6894731b63 100644 --- a/src/util/os_misc.c +++ b/src/util/os_misc.c @@ -48,7 +48,11 @@ #endif -#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD +#if DETECT_OS_ANDROID +# define LOG_TAG "MESA" +# include +# include +#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD # include #elif DETECT_OS_APPLE || DETECT_OS_BSD # include @@ -104,6 +108,9 @@ os_log_message(const char *message) fflush(stdout); fputs(message, fout); fflush(fout); +# if DETECT_OS_ANDROID + LOG_PRI(ANDROID_LOG_ERROR, LOG_TAG, "%s", message); +# endif #endif } -- 2.30.2