diff --git a/ets2panda/driver/build_system/src/build/base_mode.ts b/ets2panda/driver/build_system/src/build/base_mode.ts index 465492b1e76464e68a3ee4d73c2522b1567a46cf..abeb5ba7b8533042cbb7196ce9dc7d0e6e369515 100644 --- a/ets2panda/driver/build_system/src/build/base_mode.ts +++ b/ets2panda/driver/build_system/src/build/base_mode.ts @@ -762,7 +762,6 @@ export abstract class BaseMode { protected generateModuleInfos(): void { this.collectModuleInfos(); this.generateArkTSConfigForModules(); - this.generatedependencyFileMap(); this.collectCompileFiles(); this.saveHashCache(); } diff --git a/ets2panda/driver/build_system/src/build/generate_arktsconfig.ts b/ets2panda/driver/build_system/src/build/generate_arktsconfig.ts index e61ae1794740e00586aa532f26259252a44aa655..ec26e841675e95e2bc475aab66c2d206805ed39f 100644 --- a/ets2panda/driver/build_system/src/build/generate_arktsconfig.ts +++ b/ets2panda/driver/build_system/src/build/generate_arktsconfig.ts @@ -41,6 +41,8 @@ import { ModuleInfo, } from '../types'; import { + COMPONENT, + KITS, LANGUAGE_VERSION, SYSTEM_SDK_PATH_FROM_SDK, sdkConfigPrefix, @@ -283,11 +285,21 @@ export class ArkTSConfigGenerator { private processAlias(moduleInfo: ModuleInfo, dependencySection: Record): void { this.dynamicSDKPaths.forEach(basePath => { - if (fs.existsSync(basePath)) { + if(basePath.includes(KITS)){ + return; + } + if (!fs.existsSync(basePath)) { + const logData: LogData = LogDataFactory.newInstance( + ErrorCode.BUILDSYSTEM_ALIAS_MODULE_PATH_NOT_EXIST, + `alias module ${basePath} not exist.` + ); + this.logger.printErrorAndExit(logData); + } + if(basePath.includes(COMPONENT)){ + this.traverseDependencies(basePath, '', false, dependencySection,'component/'); + }else{ this.traverseDependencies(basePath, '', false, dependencySection); this.traverseDependencies(basePath, '', false, dependencySection,'dynamic/'); - } else { - this.logger.printWarn(`sdk path ${basePath} not exist.`); } }); @@ -337,7 +349,7 @@ export class ArkTSConfigGenerator { const isRuntimeAPI = path.basename(currentDir) === 'arkui' && item === 'runtime-api'; const newRelativePath = isRuntimeAPI ? '' - : (relativePath ? `${relativePath}.${item}` : item); + : (relativePath ? `${relativePath}/${item}` : item); this.traverseDependencies( path.resolve(currentDir, item), @@ -363,11 +375,12 @@ export class ArkTSConfigGenerator { baseName: string, relativePath: string, isExcludedDir: boolean, - prefix: string = '' + prefix: string = '', + separator: string = '.' ): string { return prefix + (isExcludedDir ? baseName - : (relativePath ? `${relativePath}.${baseName}` : baseName) + : (relativePath ? `${relativePath}${separator}${baseName}` : baseName) ); } @@ -380,11 +393,14 @@ export class ArkTSConfigGenerator { dependencySection, prefix = '' } = ctx; - - if (!this.isValidAPIFile(fileName)) return; - + let separator = '.' + if (!this.isValidAPIFile(fileName)){ + separator = '/' + } + const baseName = path.basename(fileName, '.d.ets'); - const key = this.buildDynamicKey(baseName, relativePath, isExcludedDir, prefix); + const normalizedRelativePath = relativePath.replace(/\//g, separator); + const key = this.buildDynamicKey(baseName, normalizedRelativePath, isExcludedDir, prefix, separator); dependencySection[key] = { language: 'js', @@ -392,7 +408,6 @@ export class ArkTSConfigGenerator { ohmUrl: getOhmurlByApi(baseName) }; } - private processStaticAlias(aliasName: string, aliasConfig: AliasConfig) { this.pathSection[aliasName] = [getInteropFilePathByApi(aliasConfig.originalAPIName, this.dynamicSDKPaths)]; diff --git a/ets2panda/driver/build_system/src/error_code.ts b/ets2panda/driver/build_system/src/error_code.ts index 85cb2ea42e2e11ee32316cf7d63141b0b3e85fcd..7099c49ea69cf76c785dafdefbe1846b7280e266 100644 --- a/ets2panda/driver/build_system/src/error_code.ts +++ b/ets2panda/driver/build_system/src/error_code.ts @@ -41,5 +41,6 @@ export enum ErrorCode { BUILDSYSTEM_INTEROP_SDK_NOT_FIND = '11410020', BUILDSYSTEM_INIT_ALIAS_CONFIG_FAILED = '11410021', BUILDSYSTEM_PLUGIN_ALIAS_CONFIG_PARSING_FAIL = '11410022', - BUILDSYSTEM_ABC_FILE_NOT_EXIST_IN_BCHAR = '11410023' + BUILDSYSTEM_ABC_FILE_NOT_EXIST_IN_BCHAR = '11410023', + BUILDSYSTEM_ALIAS_MODULE_PATH_NOT_EXIST = '11410024' } diff --git a/ets2panda/driver/build_system/src/init/process_build_config.ts b/ets2panda/driver/build_system/src/init/process_build_config.ts index 50aac6d47c1258f3ad732a4c3df528ecb4ab6904..d802b72bd8454264d577264750ddee0a1789a325 100644 --- a/ets2panda/driver/build_system/src/init/process_build_config.ts +++ b/ets2panda/driver/build_system/src/init/process_build_config.ts @@ -23,6 +23,10 @@ import { } from '../utils'; import { PluginDriver } from '../plugins/plugins_driver'; import { + API, + ARKTS, + COMPONENT, + KITS, KOALA_WRAPPER_PATH_FROM_SDK, PANDA_SDK_PATH_FROM_SDK, PROJECT_BUILD_CONFIG_FILE @@ -190,9 +194,28 @@ function initInteropSDKInfo(buildConfig: BuildConfig): void { : [path.resolve(buildConfig.buildSdkPath as string, "../ets1.1/build-tools/interop")]; for (const basePath of basePaths) { - const arktsPath = path.resolve(basePath, 'arkts'); - const apiPath = path.resolve(basePath, 'api'); - const kitsPath = path.resolve(basePath, 'kits'); + /** + * dynamic public api from 1.1 + */ + const arktsPath = path.resolve(basePath, ARKTS); + /** + * dynamic public api from 1.1 + */ + const apiPath = path.resolve(basePath, API); + /** + * a router file from 1.1, whicl will export * from manay api file + * and kit have not runtime_name,is alias for edit, + * and will be transformed before compile in 1.1 + */ + const kitsPath = path.resolve(basePath, KITS); + /** + * component is inner api for apiPath and artsPath + * bcs apiPath and artsPath is dynamic module, + * apiPath will depend component, we should also add component to dependenciesection, + * or it will fatal error + */ + const component = path.resolve(basePath, COMPONENT); + if (fs.existsSync(arktsPath)) { buildConfig.interopSDKPaths.add(arktsPath); @@ -203,6 +226,9 @@ function initInteropSDKInfo(buildConfig: BuildConfig): void { if (fs.existsSync(kitsPath)) { buildConfig.interopSDKPaths.add(kitsPath); } + if (fs.existsSync(component)) { + buildConfig.interopSDKPaths.add(component); + } } } diff --git a/ets2panda/driver/build_system/src/plugins/KitImportTransformer.ts b/ets2panda/driver/build_system/src/plugins/KitImportTransformer.ts index 6d6f19b6af8ff9860e10d338a9731e558e686d82..da82b98865b0ddc83ee9ff61fcd5bdeddde22449 100644 --- a/ets2panda/driver/build_system/src/plugins/KitImportTransformer.ts +++ b/ets2panda/driver/build_system/src/plugins/KitImportTransformer.ts @@ -127,7 +127,7 @@ export class KitImportTransformer { continue; } - const sourcePath = 'default' + symbolEntry.source.replace(/\.d\.ts$/, ''); + const sourcePath = 'dynamic/' + symbolEntry.source.replace(/\.d\.ts$/, ''); if (!grouped.has(sourcePath)) { grouped.set(sourcePath, []); } diff --git a/ets2panda/driver/build_system/src/pre_define.ts b/ets2panda/driver/build_system/src/pre_define.ts index 3879de18ee97353a583f08448cd97cf22a7f0c05..ac3e5a0028baa8a6317c602b7d1160e630d30b59 100644 --- a/ets2panda/driver/build_system/src/pre_define.ts +++ b/ets2panda/driver/build_system/src/pre_define.ts @@ -46,3 +46,8 @@ export const NATIVE_MODULE: Set = new Set( ['system.app', 'ohos.app', 'system.router', 'system.curves', 'ohos.curves', 'system.matrix4', 'ohos.matrix4']); export const ARKTS_MODULE_NAME: string = 'arkts'; + +export const KITS: string = 'kit'; +export const API: string = 'api'; +export const ARKTS:string = 'arkts'; +export const COMPONENT:string = 'component'; \ No newline at end of file