mcst-linux-kernel/patches-2024.06.26/gl4es-1.1.4/0130-Add-a-new-option-USE_A...

91 lines
2.8 KiB
Diff

From a05e895d0ea10f513906f18f5418f18bb7baacb9 Mon Sep 17 00:00:00 2001
From: CosineMath <1365471105@qq.com>
Date: Sun, 11 Apr 2021 19:05:37 +0800
Subject: [PATCH 130/233] Add a new option USE_ANDROID_LOG
---
CMakeLists.txt | 5 +++++
src/CMakeLists.txt | 2 +-
src/gl/logs.c | 8 ++++----
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1feeb344..36d9b8c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,7 @@ option(USE_CCACHE "Set to ON to use ccache if present in the system" ${USE_CCACH
option(USE_CLOCK "Set to ON to use clock_gettime instead of gttimeofday for LIBGL_FPS" ${USE_CLOCK})
option(NO_LOADER "disable library loader (useful for static library with NOEGL, NOX11, use include/gl4esinit.h)" ${NO_LOADER})
option(NO_INIT_CONSTRUCTOR "disable automatic initialization (useful for static library, use include/gl4esinit.h)" ${NO_INIT_CONSTRUCTOR})
+option(USE_ANDROID_LOG "Set to ON to use Android log instead of " ${USE_ANDROID_LOG})
include(CheckSymbolExists)
check_symbol_exists(backtrace "execinfo.h" HAS_BACKTRACE)
@@ -81,6 +82,10 @@ endif()
if(ANDROID)
add_definitions(-DANDROID)
add_definitions(-DNOX11 -DNO_GBM -DDEFAULT_ES=2)
+endif()
+
+if(USE_ANDROID_LOG)
+ add_definitions(-DUSE_ANDROID_LOG)
find_library(log-lib log)
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b290b96a..e59c9ca6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -206,7 +206,7 @@ else()
if(USE_CLOCK)
target_link_libraries(GL rt)
endif()
- if(ANDROID)
+ if(USE_ANDROID_LOG)
target_link_libraries(GL ${log-lib})
endif()
diff --git a/src/gl/logs.c b/src/gl/logs.c
index a2018b44..0963da17 100644
--- a/src/gl/logs.c
+++ b/src/gl/logs.c
@@ -1,7 +1,7 @@
#include "logs.h"
#include "init.h"
#include <stdarg.h>
-#ifdef ANDROID
+#if defined(ANDROID) && defined(USE_ANDROID_LOG)
#include <android/log.h>
#endif
//----------------------------------------------------------------------------
@@ -11,7 +11,7 @@ void LogPrintf_NoPrefix(const char *fmt,...)
{
va_list args;
va_start(args,fmt);
- #ifdef ANDROID
+ #if defined(ANDROID) && defined(USE_ANDROID_LOG)
__android_log_vprint(ANDROID_LOG_INFO, "LIBGL", fmt, args);
#else
vprintf(fmt,args);
@@ -26,7 +26,7 @@ void LogFPrintf(FILE *fp,const char *fmt,...)
#endif
va_list args;
va_start(args,fmt);
- #ifdef ANDROID
+ #if defined(ANDROID) && defined(USE_ANDROID_LOG)
// also on logcat
__android_log_vprint(ANDROID_LOG_INFO, "LIBGL", fmt, args);
#endif
@@ -41,7 +41,7 @@ void LogPrintf(const char *fmt,...)
#endif
va_list args;
va_start(args,fmt);
- #ifdef ANDROID
+ #if defined(ANDROID) && defined(USE_ANDROID_LOG)
__android_log_vprint(ANDROID_LOG_INFO, "LIBGL", fmt, args);
#else
vprintf(fmt,args);
--
2.11.0