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 59193da7a0c69939c08da835cda3ca67aba92c5f..5bac7e6d125f1dee32f2d1da3d8a0fbd5952b69b 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 a00da5ba76debeb7ff6147d5762c3f6a9fe042b3..712a83bba20af9ee1d8f16e6b2f323fb94ff2e63 100644 --- a/ets2panda/util/importPathManager.cpp +++ b/ets2panda/util/importPathManager.cpp @@ -401,6 +401,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 @@ -424,8 +438,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 a0f525c43deb08d980bbbe62b87386b9817442bb..00d81c279559fc0c0f2f96adcd1bd2a8f918e516 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 ProcessExternalLibraryImport(ImportMetadata &importData); std::string_view TryImportFromDeclarationCache(std::string_view resolvedImportPath) const;