Skip to content

Commit

Permalink
platform: Add HarmonyOS HiLog support
Browse files Browse the repository at this point in the history
  • Loading branch information
quink-black committed Jul 3, 2024
1 parent d264b63 commit 8df90c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/platform.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 <hilog/log.h>
#define NCNN_LOGE(...) OH_LOG_ERROR(LOG_APP, ##__VA_ARGS__)
#else // NCNN_PLATFORM_API && __ANDROID_API__ >= 8
#include <stdio.h>
#define NCNN_LOGE(...) do { \
Expand Down

0 comments on commit 8df90c5

Please sign in to comment.