Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform: Add HarmonyOS HiLog support #5562

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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__)
Comment on lines +298 to +305
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int OH_LOG_Print(LOG_APP, LOG_WARN, LOG_DOMAIN, "ncnn", ##__VA_ARGS__)

domain could be hardcoded as any code you like here

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样不行,如果外面调用了,比如下面这种写法
NCNN_LOGE("%d", 1),转成OH_LOG_ERROR(LOG_APP, "%d", 1),这个1是不会输出出来的,按鸿蒙的文档中要写成"%{public}d"这样才能输出出来

#else // NCNN_PLATFORM_API && __ANDROID_API__ >= 8
#include <stdio.h>
#define NCNN_LOGE(...) do { \
Expand Down
Loading