From: Joonbum Ko Date: Tue, 24 Aug 2021 03:21:01 +0000 (+0900) Subject: Exclude dlog dependency when dlog disabled. X-Git-Tag: accepted/tizen/unified/20231123.124504~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Flinux_yocto;p=platform%2Fhal%2Fapi%2Ftbm.git Exclude dlog dependency when dlog disabled. Change-Id: I14d45daf2375cbd92909d2226547f466b1514476 Signed-off-by: Joonbum Ko --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 545c48d..ffccbf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,10 +17,19 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) -SET(PKG_MODULES - hal-api-common - dlog -) +if (${DEFAULT_LOG_DLOG}) + SET(PKG_MODULES + hal-api-common + dlog + ) + ADD_DEFINITIONS("-DENABLE_DLOG=1") +else() + SET(PKG_MODULES + hal-api-common + ) + ADD_DEFINITIONS("-DENABLE_DLOG=0") +endif() + INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED ${PKG_MODULES}) @@ -36,11 +45,6 @@ SET(CMAKE_EXE_LINKER_FLAGS "-pie") ADD_DEFINITIONS("-DLOG_TAG=\"HALAPI_TBM\"") -if (${DEFAULT_LOG_DLOG}) - ADD_DEFINITIONS("-DENABLE_DLOG=1") -else() - ADD_DEFINITIONS("-DENABLE_DLOG=0") -endif() SET(SRCS src/hal-api-tbm.c diff --git a/src/common.h b/src/common.h index 729a431..f151a07 100644 --- a/src/common.h +++ b/src/common.h @@ -35,7 +35,9 @@ #include #include +#if ENABLE_DLOG #include +#endif /* log level */ void hal_tbm_log_print(int level, const char *fmt, ...); diff --git a/src/hal-tbm-log.c b/src/hal-tbm-log.c index 5a31ce3..775e6ea 100644 --- a/src/hal-tbm-log.c +++ b/src/hal-tbm-log.c @@ -1,5 +1,4 @@ #include -#include #include "hal-tbm-types.h" #include "common.h" @@ -11,8 +10,10 @@ #define COLOR_RESET "\x1b[0m" #if ENABLE_DLOG +#include static unsigned int dlog_enable = 1; #else +#include static unsigned int dlog_enable = 0; #endif static unsigned int color_enable = 1; @@ -39,6 +40,7 @@ _tbm_log_vprint_stdout(int level, const char *fmt, va_list arg) printf("\n"); } +#if ENABLE_DLOG static void _tbm_log_dlog_print(int level, const char *fmt, va_list arg) { @@ -62,6 +64,7 @@ _tbm_log_dlog_print(int level, const char *fmt, va_list arg) } __dlog_vprint(LOG_ID_SYSTEM, dlog_prio, LOG_TAG, fmt, arg); } +#endif void hal_tbm_log_print(int level, const char *fmt, ...) @@ -71,11 +74,15 @@ hal_tbm_log_print(int level, const char *fmt, ...) if (level > tbm_log_debug_level) return; +#if ENABLE_DLOG if (dlog_enable) { va_start(arg, fmt); _tbm_log_dlog_print(level, fmt, arg); va_end(arg); - } else { + } + else +#endif + { va_start(arg, fmt); _tbm_log_vprint_stdout(level, fmt, arg); va_end(arg);