mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
Fix bug for mergeAbcPath of the application
issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I5XIRT?from=project-issue Signed-off-by: lifansheng <lifansheng1@huawei.com> Change-Id: I8251d837bbb04d4d3f83db15a94d7c414fedaa9b
This commit is contained in:
@@ -60,7 +60,8 @@ constexpr char ARK_DEBUGGER_LIB_PATH[] = "/system/lib/libark_debugger.z.so";
|
||||
#endif
|
||||
|
||||
constexpr char TIMER_TASK[] = "uv_timer_task";
|
||||
static constexpr char MERGE_ABC_PATH[] = "/data/storage/el1/bundle/entry/ets/modules.abc";
|
||||
constexpr char MERGE_ABC_PATH[] = "/ets/modules.abc";
|
||||
constexpr char BUNDLE_INSTALL_PATH[] = "/data/storage/el1/bundle/";
|
||||
|
||||
class ArkJsRuntime : public JsRuntime {
|
||||
public:
|
||||
@@ -138,7 +139,16 @@ public:
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
if (!runtimeExtractor->GetFileBuffer(MERGE_ABC_PATH, outStream)) {
|
||||
std::string mergeAbcPath;
|
||||
if (vm_ && !moduleName_.empty()) {
|
||||
mergeAbcPath = BUNDLE_INSTALL_PATH + moduleName_ + MERGE_ABC_PATH;
|
||||
panda::JSNApi::SetAssetPath(vm_, mergeAbcPath);
|
||||
} else {
|
||||
HILOG_ERROR("vm is nullptr or moduleName is hole");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!runtimeExtractor->GetFileBuffer(mergeAbcPath, outStream)) {
|
||||
HILOG_ERROR("Get Module abc file failed");
|
||||
return result;
|
||||
}
|
||||
@@ -613,6 +623,13 @@ std::unique_ptr<NativeReference> JsRuntime::LoadModule(
|
||||
moduleName.c_str(), modulePath.c_str(), hapPath.c_str(), esmodule ? "true" : "false");
|
||||
HandleScope handleScope(*this);
|
||||
|
||||
std::string path = moduleName;
|
||||
auto pos = path.find("::");
|
||||
if (pos != std::string::npos) {
|
||||
path.erase(pos, path.size() - pos);
|
||||
moduleName_ = path;
|
||||
}
|
||||
|
||||
NativeValue* classValue = nullptr;
|
||||
|
||||
auto it = modules_.find(modulePath);
|
||||
@@ -689,7 +706,8 @@ bool JsRuntime::RunScript(const std::string& srcPath, const std::string& hapPath
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
if (!runtimeExtractor->GetFileBuffer(MERGE_ABC_PATH, outStream)) {
|
||||
std::string mergeAbcPath = BUNDLE_INSTALL_PATH + moduleName_ + MERGE_ABC_PATH;
|
||||
if (!runtimeExtractor->GetFileBuffer(mergeAbcPath, outStream)) {
|
||||
HILOG_ERROR("Get Module abc file failed");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ protected:
|
||||
bool isBundle_ = true;
|
||||
std::unique_ptr<NativeEngine> nativeEngine_;
|
||||
std::string codePath_;
|
||||
std::string moduleName_;
|
||||
std::unique_ptr<NativeReference> methodRequireNapiRef_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> eventHandler_;
|
||||
std::unordered_map<std::string, NativeReference*> modules_;
|
||||
|
||||
Reference in New Issue
Block a user