From 6c9692cf4bf71bba529e6c75547d56ff0e22bc37 Mon Sep 17 00:00:00 2001 From: tension <1113989231@qq.com> Date: Sat, 30 Aug 2025 16:07:29 +0800 Subject: [PATCH] Pick8047to0728 Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICVKDT?from=project-issue Signed-off-by: zhangli <1113989231@qq.com> Change-id: af8cb9f75a812ca667a14e489b3a78bc15a4a18ac --- .../test/demo_hap/build_config.json | 49 ++++++++++++++----- ets2panda/util/importPathManager.cpp | 18 ++++++- ets2panda/util/importPathManager.h | 1 + 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/ets2panda/driver/build_system/test/demo_hap/build_config.json b/ets2panda/driver/build_system/test/demo_hap/build_config.json index 59193da7a0..5bac7e6d12 100644 --- a/ets2panda/driver/build_system/test/demo_hap/build_config.json +++ b/ets2panda/driver/build_system/test/demo_hap/build_config.json @@ -1,4 +1,8 @@ { + "plugins": { + "ArkUI": "${absolute_path_to_build_system}/test/mock_sdk/ets/ets1.2/build-tools/ui-plugins/lib/ui-plugins/index.js", + "ArkUI-Memo": "${absolute_path_to_build_system}/test/mock_sdk/ets/ets1.2/build-tools/ui-plugins/lib/memo-plugins/index.js" + }, "compileFiles": [ "${absolute_path_to_build_system}/test/demo_hap/entry/b.ets", "${absolute_path_to_build_system}/test/demo_hap/entry/c.ets", @@ -6,31 +10,43 @@ "${absolute_path_to_build_system}/test/demo_hap/harA/index.ets", "${absolute_path_to_build_system}/test/demo_hap/harB/indexB.ets" ], - - "packageName": "entry", - "moduleType": "shared", - + "packageName": "library", + "moduleType": "har", "buildType": "build", "buildMode": "Debug", - "moduleRootPath": "${absolute_path_to_build_system}/test/demo_hap/entry/", - "sourceRoots": ["./", "src/main1/ets"], - + "moduleRootPath": "${absolute_path_to_build_system}/test/e2e/demo_file1.2_file1.1_file1.1", + "sourceRoots": [ + "./" + ], + "bundleName": "com.example.myapplication", "loaderOutPath": "./dist", "cachePath": "./dist/cache", - "enableDeclgenEts2Ts": false, "declgenV1OutPath": "./dist/declgen/decl_ets", "declgenBridgeCodePath": "./dist/declgen/ets", - "buildSdkPath": "${absolute_path_to_build_system}/test/mock_sdk/", - + "compileSdkVersion": 20, + "compatibleSdkVersion": 20, "dependentModuleList": [ + { + "packageName": "entry", + "moduleName": "entry", + "moduleType": "feature", + "modulePath": "${absolute_path_to_build_system}/test/demo_hap/entry", + "sourceRoots": [ + "./" + ], + "entryFile": "a.ets", + "language": "1.2" + }, { "packageName": "harA", "moduleName": "harA", "moduleType": "har", "modulePath": "${absolute_path_to_build_system}/test/demo_hap/harA", - "sourceRoots": ["./"], + "sourceRoots": [ + "./" + ], "entryFile": "index.ets", "language": "1.2" }, @@ -39,9 +55,18 @@ "moduleName": "harB", "moduleType": "har", "modulePath": "${absolute_path_to_build_system}/test/demo_hap/harB", - "sourceRoots": ["./"], + "sourceRoots": [ + "./" + ], "entryFile": "indexB.ets", "language": "1.2" } + ], + "entryFile": [ + "${absolute_path_to_build_system}/test/demo_hap/entry/b.ets", + "${absolute_path_to_build_system}/test/demo_hap/entry/c.ets", + "${absolute_path_to_build_system}/test/demo_hap/entry/d.ets", + "${absolute_path_to_build_system}/test/demo_hap/harA/index.ets", + "${absolute_path_to_build_system}/test/demo_hap/harB/indexB.ets" ] } \ No newline at end of file diff --git a/ets2panda/util/importPathManager.cpp b/ets2panda/util/importPathManager.cpp index 9b64cc0f4b..5594810568 100644 --- a/ets2panda/util/importPathManager.cpp +++ b/ets2panda/util/importPathManager.cpp @@ -363,6 +363,20 @@ std::string ImportPathManager::TryMatchDependencies(std::string_view fixedPath) return {}; } +std::string ImportPathManager::TryResolvePath(std::string_view fixedPath) const +{ + auto normalizedPath = ark::os::NormalizePath(std::string(fixedPath)); + std::replace_if( + normalizedPath.begin(), normalizedPath.end(), [&](auto &c) { return c == pathDelimiter_[0]; }, '/'); + if (arktsConfig_->Dependencies().find(normalizedPath) != arktsConfig_->Dependencies().cend()) { + return normalizedPath; + } + if (arktsConfig_->Paths().find(normalizedPath) != arktsConfig_->Paths().cend()) { + return normalizedPath; + } + return {}; +} + std::string_view ImportPathManager::DirOrDirWithIndexFile(StringView dir) const { // Supported index files: keep this checking order @@ -386,8 +400,8 @@ ImportPathManager::ResolvedPathRes ImportPathManager::AppendExtensionOrIndexFile std::replace_if( fixedPath.begin(), fixedPath.end(), [&](auto &c) { return ((delim != c) && ((c == '\\') || (c == '/'))); }, delim); - if (auto resolvedDynamic = TryMatchDependencies(fixedPath); !resolvedDynamic.empty()) { - return {UString(resolvedDynamic, allocator_).View().Utf8(), true}; + if (auto resolvedPath = TryResolvePath(fixedPath); !resolvedPath.empty()) { + return {UString(resolvedPath, allocator_).View().Utf8(), true}; } auto path = UString(fixedPath, allocator_).View(); diff --git a/ets2panda/util/importPathManager.h b/ets2panda/util/importPathManager.h index 04c4742836..17703ef1b2 100644 --- a/ets2panda/util/importPathManager.h +++ b/ets2panda/util/importPathManager.h @@ -183,6 +183,7 @@ private: std::string_view DirOrDirWithIndexFile(StringView dir) const; ResolvedPathRes AppendExtensionOrIndexFileIfOmitted(StringView basePath) const; std::string TryMatchDependencies(std::string_view fixedPath) const; + std::string TryResolvePath(std::string_view fixedPath) const; StringView GetRealPath(StringView path) const; void ProcessExternalModuleImport(ImportMetadata &importData); -- Gitee