diff --git a/bundle.json b/bundle.json index 7ddfc3d10f7ca5e724db41909074927a678d41e1..bb92516c5af95b4ad3467e42d11173495361714d 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 a7d21c529fd8af39b795b7c74db0b1663a96b59b..c315f2cdbd5d676f6e90d829c7ac1177281f6d46 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 4f22b3ed3e49346cb1b0f81c647044e54ae9dc01..1c27ffc555d95fb860b220ab90bb9f12181a7f75 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() {