[babl] babl: babl_log() implementation for Android.



commit ccf902d07cff18ca0f3ea79be56dfd7ffcdda375
Author: Jehan <jehan girinstud io>
Date:   Tue Jul 4 16:35:46 2017 +0200

    babl: babl_log() implementation for Android.

 babl/Makefile.am     |    2 +-
 babl/babl-internal.h |   23 ++++++++++++++++++++++-
 configure.ac         |    3 +++
 3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/babl/Makefile.am b/babl/Makefile.am
index bc13d95..c902325 100644
--- a/babl/Makefile.am
+++ b/babl/Makefile.am
@@ -99,7 +99,7 @@ libbabl_@BABL_API_VERSION@_la_LIBADD= \
        @LTLIBOBJS@
 
 libbabl_@BABL_API_VERSION@_la_LDFLAGS=                 \
-       ${no_undefined} $(MATH_LIB) $(THREAD_LIB)       \
+       ${no_undefined} $(MATH_LIB) $(THREAD_LIB) $(LOG_LIB) \
        -version-info $(BABL_LIBRARY_VERSION)
 
 EXTRA_DIST = babl-ref-pixels.inc
diff --git a/babl/babl-internal.h b/babl/babl-internal.h
index a4dc5f7..24ad347 100644
--- a/babl/babl-internal.h
+++ b/babl/babl-internal.h
@@ -58,6 +58,9 @@
 # define rint(f)  (floor (((double) (f)) + 0.5))
 #endif
 
+#ifdef __ANDROID_API__
+#include <android/log.h>
+#endif
 
 
 Babl *   babl_conversion_find           (const void     *source,
@@ -123,15 +126,33 @@ real_babl_log_va(const char *file,
   if (extender != babl_extension_quiet_log())
     {
       if (babl_extender())
-        fprintf (stdout, "When loading %s:\n\t", babl_extender()->instance.name);
+        {
+#ifdef __ANDROID_API__
+          __android_log_print (ANDROID_LOG_DEBUG, "BABL",
+                               "When loading %s:\n\t", babl_extender()->instance.name);
+#else
+          fprintf (stdout, "When loading %s:\n\t", babl_extender()->instance.name);
+#endif
+        }
 
+#ifdef __ANDROID_API__
+      __android_log_print (ANDROID_LOG_DEBUG, "BABL",
+                           "%s:%i %s()\n\t", file, line, function);
+#else
       fprintf (stdout, "%s:%i %s()\n\t", file, line, function);
+#endif
     }
 
+#ifdef __ANDROID_API__
+  __android_log_vprint (ANDROID_LOG_DEBUG, "BABL",
+                        fmt, varg);
+  __android_log_write (ANDROID_LOG_DEBUG, "BABL", "\n");
+#else
   vfprintf (stdout, fmt, varg);
 
   fprintf (stdout, "\n");
   fflush (NULL);
+#endif
   return;
 }
 
diff --git a/configure.ac b/configure.ac
index 08d10ac..4abcfca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -255,6 +255,7 @@ AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
 
 MATH_LIB=-lm
 THREAD_LIB=-lpthread
+LOG_LIB=
 AC_MSG_CHECKING([for native Win32])
 case "$target_or_host" in
   *-*-mingw*)
@@ -269,6 +270,7 @@ case "$target_or_host" in
     PATH_SEP=':'
     DIR_SEP='/'
     THREAD_LIB=
+    LOG_LIB='-llog'
     ;;
   *)
     os_win32=no
@@ -281,6 +283,7 @@ AC_SUBST(PATH_SEP)
 AC_SUBST(DIR_SEP)
 AC_SUBST(MATH_LIB)
 AC_SUBST(THREAD_LIB)
+AC_SUBST(LOG_LIB)
 
 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
 AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]