From 40448e4749cdd6fa07c8bc0e4c1320abaf032731 Mon Sep 17 00:00:00 2001 From: wangyimin Date: Mon, 16 Dec 2024 11:13:35 +0800 Subject: [PATCH] fix emulator Signed-off-by: wangyimin --- configure.py | 4 +--- jsvm/src/platform/platform_ohos.cc | 6 ++++++ node.gyp | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/configure.py b/configure.py index cc33a3fa0..b8ae1122b 100644 --- a/configure.py +++ b/configure.py @@ -1284,10 +1284,8 @@ def configure_node(o): o['variables']['host_arch'] = host_arch o['variables']['target_arch'] = target_arch o['variables']['node_byteorder'] = sys.byteorder - if options.target_platform in ('pc', 'emulator'): + if options.target_platform != 'phone': o['variables']['use_node_zlib'] = 'true' - - if options.target_platform == 'emulator': o['variables']['enable_hilog'] = 'false' cross_compiling = (options.cross_compiling diff --git a/jsvm/src/platform/platform_ohos.cc b/jsvm/src/platform/platform_ohos.cc index c7274a497..24a95b8a3 100644 --- a/jsvm/src/platform/platform_ohos.cc +++ b/jsvm/src/platform/platform_ohos.cc @@ -4,7 +4,9 @@ #include "v8.h" // OHOS API header +#ifdef ENABLE_HILOG #include "hilog/log.h" +#endif #include "hitrace_meter.h" #include "init_param.h" #include "unistd.h" @@ -71,6 +73,7 @@ uint64_t OS::GetTid() void OS::PrintString(LogLevel level, const char* string) { +#ifdef ENABLE_HILOG // convert platform defined LogLevel to hilog LogLevel static constexpr ::LogLevel convertArray[] = { ::LogLevel::LOG_DEBUG, ::LogLevel::LOG_INFO, ::LogLevel::LOG_WARN, ::LogLevel::LOG_ERROR, ::LogLevel::LOG_FATAL }; @@ -78,6 +81,9 @@ void OS::PrintString(LogLevel level, const char* string) // TODO: use LOG_APP or other LogType HiLogPrint(LOG_APP, convertArray[static_cast(level)], LOG_DOMAIN, LOG_TAG, "%{public}s", string); +#else + printf("%s", string); +#endif } void OS::Print(LogLevel level, const char* format, ...) diff --git a/node.gyp b/node.gyp index e187e6636..40ea42c86 100644 --- a/node.gyp +++ b/node.gyp @@ -481,6 +481,9 @@ [ 'enable_hilog=="true"' , { 'ldflags' : [ '<(NDK_SYS_ROOT)/hiviewdfx/hilog_override/libhilog.so', + ], + 'defines': [ + 'ENABLE_HILOG', ] } ], ], -- Gitee