From c3c6d5de0ef9b28b321fbcd91715f181a29b3cf1 Mon Sep 17 00:00:00 2001 From: jiangkuaixue Date: Sat, 12 Mar 2022 16:00:02 +0800 Subject: [PATCH] remove hap target and fix dlopen with musl Signed-off-by: jiangkuaixue --- bundle.json | 3 +-- ohos_nweb/BUILD.gn | 13 +++++-------- ohos_nweb/src/nweb_helper.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/bundle.json b/bundle.json index 7ddfc3d10..bb92516c5 100644 --- a/bundle.json +++ b/bundle.json @@ -30,8 +30,7 @@ }, "build": { "sub_component": [ - "//base/web/webview/ohos_nweb:libnweb", - "//base/web/webview/ohos_nweb:nweb_hap" + "//base/web/webview/ohos_nweb:libnweb" ], "inner_kits": [ { diff --git a/ohos_nweb/BUILD.gn b/ohos_nweb/BUILD.gn index a7d21c529..c315f2cdb 100644 --- a/ohos_nweb/BUILD.gn +++ b/ohos_nweb/BUILD.gn @@ -41,6 +41,10 @@ ohos_shared_library("libnweb") { "src/nweb_helper.cpp", ] + if (use_musl) { + defines = [ "NWEB_USE_MUSL" ] + } + public_deps = [ "//foundation/graphic/standard:libvsync_client", "//foundation/graphic/standard:libsurface", @@ -57,11 +61,4 @@ ohos_shared_library("libnweb") { part_name = "webview" subsystem_name = "web" -} - -ohos_prebuilt_etc("nweb_hap") { - source = "prebuilts/arm/NWeb.hap" - module_install_dir = "app" - part_name = "webview" - subsystem_name = "web" -} +} \ No newline at end of file diff --git a/ohos_nweb/src/nweb_helper.cpp b/ohos_nweb/src/nweb_helper.cpp index 4f22b3ed3..1c27ffc55 100644 --- a/ohos_nweb/src/nweb_helper.cpp +++ b/ohos_nweb/src/nweb_helper.cpp @@ -24,6 +24,32 @@ NWebHelper &NWebHelper::Instance() return helper; } +#ifdef NWEB_USE_MUSL +bool NWebHelper::LoadLib() +{ + if (libHandleNWebAdapter_ != nullptr && libHandleWebEngine_ != nullptr) { + return true; + } + Dl_namespace dlns; + dlns_init(&dlns, "nweb_ns"); + dlns_create(&dlns, "/data/storage/el1/bundle/nweb/libs/arm"); + const std::string LIB_PATH_NWEB_ADAPTER = "libnweb_adapter.so"; + const std::string LIB_PATH_WEB_ENGINE = "libweb_engine.so"; + void *libHandleWebEngine = dlopen_ns(&dlns, LIB_PATH_WEB_ENGINE.c_str(), RTLD_NOW); + if (libHandleWebEngine == nullptr) { + WVLOG_E("fail to dlopen %{public}s, errmsg=%{public}s", LIB_PATH_WEB_ENGINE.c_str(), dlerror()); + return false; + } + libHandleWebEngine_ = libHandleWebEngine; + void *libHandleNWebAdapter = dlopen_ns(&dlns, LIB_PATH_NWEB_ADAPTER.c_str(), RTLD_NOW); + if (libHandleNWebAdapter == nullptr) { + WVLOG_E("fail to dlopen %{public}s, errmsg=%{public}s", LIB_PATH_NWEB_ADAPTER.c_str(), dlerror()); + return false; + } + libHandleNWebAdapter_ = libHandleNWebAdapter; + return true; +} +#else bool NWebHelper::LoadLib() { if (libHandleNWebAdapter_ != nullptr && libHandleWebEngine_ != nullptr) { @@ -46,6 +72,7 @@ bool NWebHelper::LoadLib() libHandleNWebAdapter_ = libHandleNWebAdapter; return true; } +#endif void NWebHelper::UnloadLib() { -- Gitee