From 8df90c54a50f9d0ed1fafeab791a5a6547eaeec0 Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Wed, 3 Jul 2024 22:31:54 +0800 Subject: [PATCH] platform: Add HarmonyOS HiLog support --- src/CMakeLists.txt | 3 +++ src/platform.h.in | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d3f55ce77900..39802a4537a4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -333,6 +333,9 @@ endif() if(NCNN_PLATFORM_API AND ANDROID) target_link_libraries(ncnn PUBLIC android jnigraphics log) endif() +if(NCNN_PLATFORM_API AND OHOS) + target_link_libraries(ncnn PUBLIC libhilog_ndk.z.so) +endif() if(WIN32) target_compile_definitions(ncnn PUBLIC NOMINMAX) diff --git a/src/platform.h.in b/src/platform.h.in index a0f17f39e315..9f0e38d91379 100644 --- a/src/platform.h.in +++ b/src/platform.h.in @@ -294,6 +294,15 @@ static inline void swap_endianness_32(void* x) #define NCNN_LOGE(...) do { \ fprintf(stderr, ##__VA_ARGS__); fprintf(stderr, "\n"); \ __android_log_print(ANDROID_LOG_WARN, "ncnn", ##__VA_ARGS__); } while(0) +#elif NCNN_PLATFORM_API && __OHOS__ +#ifndef LOG_DOMAIN +#define LOG_DOMAIN 0x6E68 +#endif +#ifndef LOG_TAG +#define LOG_TAG "ncnn" +#endif +#include +#define NCNN_LOGE(...) OH_LOG_ERROR(LOG_APP, ##__VA_ARGS__) #else // NCNN_PLATFORM_API && __ANDROID_API__ >= 8 #include #define NCNN_LOGE(...) do { \