diff --git a/build.sh b/build.sh index 327dcbc214abf27c0d849bc17a0518909071d783..e334b40b18143dcf5b3889dc16002234104e0af5 100755 --- a/build.sh +++ b/build.sh @@ -12,7 +12,7 @@ echo -e "========================== info end ==========================\n\n" echo -e "=======================cmake build info=======================" cd $root_dir/build -cmake -DUNIT_TEST=1 -DCOMPILE_LIST=true .. +cmake -DUNIT_TEST=1 -DCOMPILE_LIST=true -DCMAKE_BUILD_TYPE=Release .. make echo -e "========================== info end ==========================\n\n" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2183347b87a8fc4d592019d0b81e9ce2cb6d844..f34830248f5b998c4790bdc41fe7d5357db93f67 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,18 @@ set(LIB_STATIC "${SDK_NAME}_static") # 配置编译宏定义 +## release或debug +if(NOT CMAKE_BUILD_TYPE) + message("BUILD TYPE: DEBUG") + message("DEFINATION: \"DEBUG\"") + set(CMAKE_BUILD_TYPE "Debug") + add_definitions(-DDEBUG) +else(NOT CMAKE_BUILD_TYPE) + message("BUILD TYPE: RELEASE") + message("DEFINATION: \"RELEASE\"") + add_definitions(-DRELEASE) +endif(NOT CMAKE_BUILD_TYPE) + ## 平台相关接口 if(WIN32) message("WINDOWS PLATFORM") diff --git a/src/common_interface.c b/src/common_interface.c index 3da2995dc422cea95476a74ca28ba0fadb24d66e..8a7b90389f47fcec3e3d0fc070f211c3345832ca 100644 --- a/src/common_interface.c +++ b/src/common_interface.c @@ -3,6 +3,7 @@ */ #include "common_interface.h" #include "common_errno.h" +#include "internal_common.h" #include #include #include diff --git a/src/internal_common.c b/src/internal_common.c new file mode 100644 index 0000000000000000000000000000000000000000..f980ab39795afbe48cf520ac80797142d084530d --- /dev/null +++ b/src/internal_common.c @@ -0,0 +1,15 @@ +#include +#include + +#include "internal_common.h" + +#ifdef DEBUG + +void _internal_debug(const char *format, ...) { + va_list args; + va_start(args, format); + vprintf(format, args); + va_end(args); +} + +#endif \ No newline at end of file diff --git a/src/internal_common.h b/src/internal_common.h new file mode 100644 index 0000000000000000000000000000000000000000..f763f88f5b25005e2c9d7b082b0d5ec6779f968f --- /dev/null +++ b/src/internal_common.h @@ -0,0 +1,34 @@ +/** + * @file internal_common.h + * @author bear + * @brief 内部通用接口 + * @version 0.1 + * @date 2024-03-13 + * + * @copyright Copyright (c) 2024 + * + */ + +#include + +#ifndef INTERNAL_COMMON_H +#define INTERNAL_COMMON_H + +#ifdef DEBUG + +void _internal_debug(const char *format, ...); +#define internal_debug(x, ...) do \ +{ \ + printf("\033[32m%s:%d, function: %s, [debug] ", __FILE__, __LINE__, __FUNCTION__); \ + _internal_debug(x, ##__VA_ARGS__); \ + printf("\033[0m\n"); \ +} while (0); + +#else + +#define internal_debug(x, ...) + +#endif + + +#endif