diff --git a/ets2panda/driver/build_system/src/build/base_mode.ts b/ets2panda/driver/build_system/src/build/base_mode.ts index 93a3e9b2203afbcfe53dc9efaf85f1e89452cc65..74bdc4ac3a6db8156dd01de3cdde20fbd17d12c4 100644 --- a/ets2panda/driver/build_system/src/build/base_mode.ts +++ b/ets2panda/driver/build_system/src/build/base_mode.ts @@ -36,6 +36,7 @@ import { MERGED_ABC_FILE, TS_SUFFIX, DEPENDENCY_INPUT_FILE, + RRCORD_COMPILE_NODE } from '../pre_define'; import { changeDeclgenFileExtension, @@ -70,7 +71,7 @@ import { import { ArkTSConfigGenerator } from './generate_arktsconfig'; import { SetupClusterOptions } from '../types'; import { KitImportTransformer } from '../plugins/KitImportTransformer'; - +import { RecordTimeMem, CompileSingleData } from '../record_time_mem'; export abstract class BaseMode { public buildConfig: BuildConfig; public entryFiles: Set; @@ -145,6 +146,8 @@ export abstract class BaseMode { } public declgen(fileInfo: CompileFileInfo): void { + let compileSingleData = new CompileSingleData(fileInfo.filePath, this.buildConfig.recordType); + compileSingleData.record(RRCORD_COMPILE_NODE.SOURCE_NODE); const source = fs.readFileSync(fileInfo.filePath, 'utf8'); const moduleInfo: ModuleInfo = this.moduleInfos.get(fileInfo.packageName)!; const filePathFromModuleRoot: string = path.relative(moduleInfo.moduleRootPath, fileInfo.filePath); @@ -171,20 +174,26 @@ export abstract class BaseMode { fileInfo.arktsConfigFile, fileInfo.filePath ]).peer; + compileSingleData.record(RRCORD_COMPILE_NODE.PROGRAM_NODE, RRCORD_COMPILE_NODE.SOURCE_NODE); arktsGlobal.compilerContext = arkts.Context.createFromString(source); PluginDriver.getInstance().getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); + compileSingleData.record(RRCORD_COMPILE_NODE.PARSE_NODE, RRCORD_COMPILE_NODE.PROGRAM_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer, true); let ast = arkts.EtsScript.fromContext(); + compileSingleData.record(RRCORD_COMPILE_NODE.UI1_NODE, RRCORD_COMPILE_NODE.PARSE_NODE); PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + compileSingleData.record(RRCORD_COMPILE_NODE.CHECK_NODE, RRCORD_COMPILE_NODE.UI1_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer, true); + compileSingleData.record(RRCORD_COMPILE_NODE.UI2_NODE, RRCORD_COMPILE_NODE.CHECK_NODE); ast = arkts.EtsScript.fromContext(); PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); PluginDriver.getInstance().runPluginHook(PluginHook.CHECKED); + compileSingleData.record(RRCORD_COMPILE_NODE.DECLGEN_NODE, RRCORD_COMPILE_NODE.UI2_NODE); arkts.generateTsDeclarationsFromContext( declEtsOutputPath, @@ -193,6 +202,9 @@ export abstract class BaseMode { false ); // Generate 1.0 declaration files & 1.0 glue code this.logger.printInfo('declaration files generated'); + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.DECLGEN_NODE); + let filePath = path.join(this.cacheDir, fileInfo.packageName) + compileSingleData.writeSumSingle(filePath, '_decl'); } catch (error) { errorStatus = true; if (error instanceof Error) { @@ -214,6 +226,8 @@ export abstract class BaseMode { } public compile(fileInfo: CompileFileInfo): void { + let compileSingleData = new CompileSingleData(fileInfo.filePath, this.buildConfig.recordType); + compileSingleData.record(RRCORD_COMPILE_NODE.SOURCE_NODE); ensurePathExists(fileInfo.abcFilePath); const ets2pandaCmd: string[] = [ @@ -239,12 +253,15 @@ export abstract class BaseMode { arktsGlobal.filePath = fileInfo.filePath; arktsGlobal.config = arkts.Config.create(ets2pandaCmd).peer; const source = fs.readFileSync(fileInfo.filePath).toString(); + compileSingleData.record(RRCORD_COMPILE_NODE.PROGRAM_NODE, RRCORD_COMPILE_NODE.SOURCE_NODE); arktsGlobal.compilerContext = arkts.Context.createFromString(source); PluginDriver.getInstance().getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); + compileSingleData.record(RRCORD_COMPILE_NODE.PARSE_NODE, RRCORD_COMPILE_NODE.PROGRAM_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer); this.logger.printInfo('es2panda proceedToState parsed'); let ast = arkts.EtsScript.fromContext(); + compileSingleData.record(RRCORD_COMPILE_NODE.UI1_NODE, RRCORD_COMPILE_NODE.PARSE_NODE); if (this.buildConfig.aliasConfig?.size > 0) { // if aliasConfig is set, transform aliasName@kit.xxx to default@ohos.xxx through the plugin this.logger.printInfo('Transforming import statements with alias config'); @@ -256,11 +273,14 @@ export abstract class BaseMode { } PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); this.logger.printInfo('plugin parsed finished'); + compileSingleData.record(RRCORD_COMPILE_NODE.CHECK_NODE, RRCORD_COMPILE_NODE.UI1_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer); this.logger.printInfo('es2panda proceedToState checked'); - + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.CHECK_NODE); + if (this.hasMainModule && (this.byteCodeHar || this.moduleType === OHOS_MODULE_TYPE.SHARED)) { + compileSingleData.record(RRCORD_COMPILE_NODE.DECLGEN_NODE); let filePathFromModuleRoot: string = path.relative(this.moduleRootPath, fileInfo.filePath); let declEtsOutputPath: string = changeFileExtension( path.join(this.declgenV2OutPath as string, this.packageName, filePathFromModuleRoot), @@ -270,15 +290,18 @@ export abstract class BaseMode { // Generate 1.2 declaration files(a temporary solution while binary import not pushed) arkts.generateStaticDeclarationsFromContext(declEtsOutputPath); + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.DECLGEN_NODE); } - + compileSingleData.record(RRCORD_COMPILE_NODE.UI2_NODE); ast = arkts.EtsScript.fromContext(); PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); PluginDriver.getInstance().runPluginHook(PluginHook.CHECKED); this.logger.printInfo('plugin checked finished'); - + compileSingleData.record(RRCORD_COMPILE_NODE.BIN_NODE, RRCORD_COMPILE_NODE.UI2_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED, arktsGlobal.compilerContext.peer); this.logger.printInfo('es2panda bin generated'); + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.BIN_NODE); + compileSingleData.writeSumSingle(path.dirname(fileInfo.abcFilePath)); } catch (error) { errorStatus = true; if (error instanceof Error) { @@ -300,7 +323,39 @@ export abstract class BaseMode { } } + private compileMultiFilesProcess(arktsGlobal: ArkTSGlobal, arkts: ArkTS, compileSingleData: CompileSingleData): void { + compileSingleData.record(RRCORD_COMPILE_NODE.PROGRAM_NODE, RRCORD_COMPILE_NODE.SOURCE_NODE); + //@ts-ignore + arktsGlobal.compilerContext = arkts.Context.createContextGenerateAbcForExternalSourceFiles(this.buildConfig.compileFiles);; + PluginDriver.getInstance().getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); + + compileSingleData.record(RRCORD_COMPILE_NODE.PARSE_NODE, RRCORD_COMPILE_NODE.PROGRAM_NODE); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer); + this.logger.printInfo('es2panda proceedToState parsed'); + let ast = arkts.EtsScript.fromContext(); + PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + compileSingleData.record(RRCORD_COMPILE_NODE.CHECK_NODE, RRCORD_COMPILE_NODE.PARSE_NODE); + this.logger.printInfo('plugin parsed finished'); + + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer); + this.logger.printInfo('es2panda proceedToState checked'); + + ast = arkts.EtsScript.fromContext(); + PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); + PluginDriver.getInstance().runPluginHook(PluginHook.CHECKED); + compileSingleData.record(RRCORD_COMPILE_NODE.BIN_NODE, RRCORD_COMPILE_NODE.CHECK_NODE); + this.logger.printInfo('plugin checked finished'); + + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED, arktsGlobal.compilerContext.peer); + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.BIN_NODE); + compileSingleData.writeSumSingle(this.cacheDir); + this.logger.printInfo('es2panda bin generated'); + } + public compileMultiFiles(filePaths: string[], moduleInfo: ModuleInfo): void { + let compileSingleData = new CompileSingleData(path.resolve(this.outputDir, MERGED_ABC_FILE), this.buildConfig.recordType); + compileSingleData.record(RRCORD_COMPILE_NODE.SOURCE_NODE); let ets2pandaCmd: string[] = [ '_', '--extension', @@ -323,27 +378,7 @@ export abstract class BaseMode { let errorStatus = false; try { arktsGlobal.config = arkts.Config.create(ets2pandaCmd).peer; - //@ts-ignore - arktsGlobal.compilerContext = arkts.Context.createContextGenerateAbcForExternalSourceFiles(this.buildConfig.compileFiles);; - PluginDriver.getInstance().getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); - - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer); - this.logger.printInfo('es2panda proceedToState parsed'); - let ast = arkts.EtsScript.fromContext(); - PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); - PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - this.logger.printInfo('plugin parsed finished'); - - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer); - this.logger.printInfo('es2panda proceedToState checked'); - - ast = arkts.EtsScript.fromContext(); - PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); - PluginDriver.getInstance().runPluginHook(PluginHook.CHECKED); - this.logger.printInfo('plugin checked finished'); - - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED, arktsGlobal.compilerContext.peer); - this.logger.printInfo('es2panda bin generated'); + this.compileMultiFilesProcess(arktsGlobal, arkts, compileSingleData); } catch (error) { errorStatus = true; throw error; @@ -358,6 +393,7 @@ export abstract class BaseMode { } public mergeAbcFiles(): void { + RecordTimeMem.getInstance().start('mergeAbcFiles'); let linkerInputFile: string = path.join(this.cacheDir, LINKER_INPUT_FILE); let linkerInputContent: string = ''; this.abcFiles.forEach((abcFile: string) => { @@ -390,6 +426,7 @@ export abstract class BaseMode { this.logger.printError(logData); } } + RecordTimeMem.getInstance().end('mergeAbcFiles'); } private getDependentModules(moduleInfo: ModuleInfo): Map[] { @@ -444,10 +481,12 @@ export abstract class BaseMode { } protected generateArkTSConfigForModules(): void { + RecordTimeMem.getInstance().start('generateArkTSConfigForModules'); this.moduleInfos.forEach((moduleInfo: ModuleInfo, moduleRootPath: string) => { ArkTSConfigGenerator.getInstance(this.buildConfig, this.moduleInfos) .writeArkTSConfigFile(moduleInfo, this.enableDeclgenEts2Ts, this.buildConfig); }); + RecordTimeMem.getInstance().end('generateArkTSConfigForModules'); } private collectDepModuleInfos(): void { @@ -466,6 +505,7 @@ export abstract class BaseMode { ); this.logger.printError(logData); } + RecordTimeMem.getInstance().start('collectModuleInfos'); const mainModuleInfo: ModuleInfo = this.getMainModuleInfo(); this.moduleInfos.set(this.packageName, mainModuleInfo); this.dependentModuleList.forEach((module: DependentModuleConfig) => { @@ -502,6 +542,7 @@ export abstract class BaseMode { this.moduleInfos.set(module.packageName, moduleInfo); }); this.collectDepModuleInfos(); + RecordTimeMem.getInstance().end('collectModuleInfos'); } protected getMainModuleInfo(): ModuleInfo { @@ -552,8 +593,10 @@ export abstract class BaseMode { } private saveHashCache(): void { + RecordTimeMem.getInstance().start('saveHashCache'); ensurePathExists(this.hashCacheFile); fs.writeFileSync(this.hashCacheFile, JSON.stringify(this.hashCache, null, 2)); + RecordTimeMem.getInstance().end('saveHashCache'); } private isFileChanged(etsFilePath: string, abcFilePath: string): boolean { @@ -726,6 +769,7 @@ export abstract class BaseMode { ); this.logger.printError(logData); }); + RecordTimeMem.getInstance().end('collectCompileFiles'); } protected collectAbcFileFromByteCodeHar(): void { @@ -734,6 +778,7 @@ export abstract class BaseMode { if (this.buildConfig.moduleType === OHOS_MODULE_TYPE.HAR) { return; } + RecordTimeMem.getInstance().start('collectAbcFileFromByteCodeHar'); for (const [packageName, moduleInfo] of this.moduleInfos) { if (!(moduleInfo.moduleType === OHOS_MODULE_TYPE.HAR && moduleInfo.byteCodeHar)) { continue; @@ -758,6 +803,7 @@ export abstract class BaseMode { } this.abcFiles.add(moduleInfo.abcPath); } + RecordTimeMem.getInstance().end('collectAbcFileFromByteCodeHar'); } protected generateModuleInfos(): void { @@ -771,6 +817,7 @@ export abstract class BaseMode { public async generateDeclaration(): Promise { this.generateModuleInfos(); + RecordTimeMem.getInstance().start('declgen'); const compilePromises: Promise[] = []; this.compileFiles.forEach((fileInfo: CompileFileInfo, _: string) => { compilePromises.push(new Promise((resolve) => { @@ -778,12 +825,15 @@ export abstract class BaseMode { resolve(); })); }); + RecordTimeMem.getInstance().end('declgen'); await Promise.all(compilePromises); + RecordTimeMem.getInstance().writeSum(this.cacheDir); } public async run(): Promise { this.generateModuleInfos(); + RecordTimeMem.getInstance().start('compileMultiFiles'); const compilePromises: Promise[] = []; let moduleToFile = new Map(); this.compileFiles.forEach((fileInfo: CompileFileInfo, file: string) => { @@ -795,6 +845,8 @@ export abstract class BaseMode { try { //@ts-ignore this.compileMultiFiles([], this.moduleInfos.get(this.packageName)); + RecordTimeMem.getInstance().end('compileMultiFiles'); + RecordTimeMem.getInstance().writeSum(this.cacheDir); } catch (error) { if (error instanceof Error) { const logData: LogData = LogDataFactory.newInstance( @@ -818,6 +870,7 @@ export abstract class BaseMode { if (this.enableDeclgenEts2Ts) { return; } + RecordTimeMem.getInstance().start('generatedependencyFileMap'); const dependencyInputFile: string = path.join(this.cacheDir, DEPENDENCY_INPUT_FILE); let dependencyInputContent: string = ''; this.entryFiles.forEach((entryFile: string) => { @@ -875,6 +928,7 @@ export abstract class BaseMode { this.logger.printError(logData); } } + RecordTimeMem.getInstance().end('generatedependencyFileMap'); } public async runParallel(): Promise { @@ -889,7 +943,9 @@ export abstract class BaseMode { clearExitListeners: true, execPath: path.resolve(__dirname, 'compile_worker.js'), }); + RecordTimeMem.getInstance().start('compiles in tasks'); await this.dispatchTasks(); + RecordTimeMem.getInstance().end('compiles in tasks'); this.logger.printInfo('All tasks complete, merging...'); this.mergeAbcFiles(); } catch (error) { @@ -899,6 +955,7 @@ export abstract class BaseMode { )); } finally { this.terminateAllWorkers(); + RecordTimeMem.getInstance().writeSum(this.cacheDir); } } @@ -915,7 +972,9 @@ export abstract class BaseMode { clearExitListeners: true, execPath: path.resolve(__dirname, 'declgen_worker.js'), }); + RecordTimeMem.getInstance().start('declaration in tasks'); await this.dispatchTasks(); + RecordTimeMem.getInstance().end('declaration in tasks'); this.logger.printInfo('All declaration generation tasks complete.'); } catch (error) { this.logger.printError(LogDataFactory.newInstance( @@ -924,6 +983,7 @@ export abstract class BaseMode { )); } finally { this.terminateAllWorkers(); + RecordTimeMem.getInstance().writeSum(this.cacheDir); } } @@ -1479,7 +1539,10 @@ export abstract class BaseMode { const processingJobs = new Set(); const workers: ThreadWorker[] = []; + RecordTimeMem.getInstance().start('compile and merge in workers'); await this.invokeWorkers(jobs, queues, processingJobs, workers); + RecordTimeMem.getInstance().end('compile and merge in workers'); + RecordTimeMem.getInstance().writeSum(this.cacheDir); } } diff --git a/ets2panda/driver/build_system/src/build/build_mode.ts b/ets2panda/driver/build_system/src/build/build_mode.ts index 0f14d3e8bab646f3591f724fcbfae0399e0f4e99..715574e1441ca4e6237d6021012ac0521213ac9b 100644 --- a/ets2panda/driver/build_system/src/build/build_mode.ts +++ b/ets2panda/driver/build_system/src/build/build_mode.ts @@ -18,6 +18,8 @@ import { BuildConfig, ES2PANDA_MODE } from '../types'; +import { RecordTimeMem } from '../record_time_mem' +import { RECORD_COMPILE_TYPE } from '../pre_define' export class BuildMode extends BaseMode { constructor(buildConfig: BuildConfig) { @@ -25,10 +27,12 @@ export class BuildMode extends BaseMode { } public async generateDeclaration(): Promise { + RecordTimeMem.getInstance().setCompileType(RECORD_COMPILE_TYPE.DELC_TYPE); await super.generateDeclarationParallell(); } public async run(): Promise { + RecordTimeMem.getInstance().setCompileType(RECORD_COMPILE_TYPE.RUN_TYPE); if (this.es2pandaMode === ES2PANDA_MODE.RUN_PARALLEL) { // RUN_PARALLEL: Executes tasks using multiple processes await super.runParallel(); diff --git a/ets2panda/driver/build_system/src/build/compile_thread_worker.ts b/ets2panda/driver/build_system/src/build/compile_thread_worker.ts index 49644a1a6db1d0c9e2c79a468765f33728b6982d..94a341170d25137b131fd911786748be62a75a36 100644 --- a/ets2panda/driver/build_system/src/build/compile_thread_worker.ts +++ b/ets2panda/driver/build_system/src/build/compile_thread_worker.ts @@ -23,7 +23,8 @@ import { } from '../utils'; import { DECL_ETS_SUFFIX, - KOALA_WRAPPER_PATH_FROM_SDK + KOALA_WRAPPER_PATH_FROM_SDK, + RRCORD_COMPILE_NODE } from '../pre_define'; import { PluginDriver, PluginHook } from '../plugins/plugins_driver'; import { @@ -37,6 +38,7 @@ import { Logger } from '../logger'; import { ErrorCode } from '../error_code'; +import { CompileSingleData } from '../record_time_mem'; import { KitImportTransformer } from '../plugins/KitImportTransformer'; const { workerId } = workerData; @@ -52,6 +54,7 @@ function compileAbc(jobInfo: JobInfo): void { let errorStatus = false; try { let fileInfo = jobInfo.compileFileInfo; + let compileSingleData = new CompileSingleData(fileInfo.filePath, config.recordType); ensurePathExists(fileInfo.abcFilePath); const ets2pandaCmd = [ @@ -71,8 +74,9 @@ function compileAbc(jobInfo: JobInfo): void { let context = arkts.Context.createCacheContextFromFile(arkConfig, fileInfo.filePath, jobInfo.globalContextPtr, false).peer; PluginDriver.getInstance().getPluginContext().setContextPtr(context); - + compileSingleData.record(RRCORD_COMPILE_NODE.PARSE_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, context); + compileSingleData.record(RRCORD_COMPILE_NODE.UI1_NODE, RRCORD_COMPILE_NODE.PARSE_NODE); if (config.aliasConfig?.size > 0) { // if aliasConfig is set, transform aliasName@kit.xxx to default@ohos.xxx through the plugin let ast = arkts.EtsScript.fromContext(); @@ -81,10 +85,12 @@ function compileAbc(jobInfo: JobInfo): void { PluginDriver.getInstance().getPluginContext().setArkTSAst(transformAst); } PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + compileSingleData.record(RRCORD_COMPILE_NODE.CHECK_NODE, RRCORD_COMPILE_NODE.UI1_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, context); - + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.CHECK_NODE); if (config.hasMainModule && (config.byteCodeHar || config.moduleType === OHOS_MODULE_TYPE.SHARED)) { + compileSingleData.record(RRCORD_COMPILE_NODE.DECLGEN_NODE); let filePathFromModuleRoot: string = path.relative(config.moduleRootPath, fileInfo.filePath); let declEtsOutputPath: string = changeFileExtension( path.join(config.declgenV2OutPath as string, config.packageName, filePathFromModuleRoot), @@ -94,11 +100,15 @@ function compileAbc(jobInfo: JobInfo): void { // Generate 1.2 declaration files(a temporary solution while binary import not pushed) arkts.generateStaticDeclarationsFromContext(declEtsOutputPath); + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.DECLGEN_NODE); } + compileSingleData.record(RRCORD_COMPILE_NODE.UI2_NODE); PluginDriver.getInstance().runPluginHook(PluginHook.CHECKED); - + compileSingleData.record(RRCORD_COMPILE_NODE.BIN_NODE, RRCORD_COMPILE_NODE.UI2_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED, context); + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.BIN_NODE); + compileSingleData.writeSumSingle(path.dirname(fileInfo.abcFilePath)); } catch (error) { errorStatus = true; if (error instanceof Error) { @@ -130,6 +140,7 @@ function compileExternalProgram(jobInfo: JobInfo): void { let errorStatus = false; try { let fileInfo = jobInfo.compileFileInfo; + let compileSingleData = new CompileSingleData(fileInfo.filePath, config.recordType); const ets2pandaCmd = ['-', '--extension', 'ets', '--arktsconfig', fileInfo.arktsConfigFile]; if (isDebug) { @@ -144,15 +155,22 @@ function compileExternalProgram(jobInfo: JobInfo): void { PluginDriver.getInstance().getPluginContext().setContextPtr(context); + compileSingleData.record(RRCORD_COMPILE_NODE.PARSE_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, context); - + compileSingleData.record(RRCORD_COMPILE_NODE.UI1_NODE, RRCORD_COMPILE_NODE.PARSE_NODE); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + compileSingleData.record(RRCORD_COMPILE_NODE.CHECK_NODE, RRCORD_COMPILE_NODE.UI1_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, context); + compileSingleData.record(RRCORD_COMPILE_NODE.UI2_NODE, RRCORD_COMPILE_NODE.CHECK_NODE); PluginDriver.getInstance().runPluginHook(PluginHook.CHECKED); + compileSingleData.record(RRCORD_COMPILE_NODE.LOWER_NODE, RRCORD_COMPILE_NODE.UI2_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_LOWERED, context); + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.LOWER_NODE); + let filePath = path.join(config.cachePath, fileInfo.packageName) + compileSingleData.writeSumSingle(filePath, '_external'); } catch (error) { errorStatus = true; if (error instanceof Error) { diff --git a/ets2panda/driver/build_system/src/build/compile_worker.ts b/ets2panda/driver/build_system/src/build/compile_worker.ts index d9f719d3eb8b8abf84170b9983cfe4667b82f497..8dfa1a508c402d61366c0c3035990bcccc97fd7a 100644 --- a/ets2panda/driver/build_system/src/build/compile_worker.ts +++ b/ets2panda/driver/build_system/src/build/compile_worker.ts @@ -22,7 +22,8 @@ import { } from '../utils'; import { DECL_ETS_SUFFIX, - KOALA_WRAPPER_PATH_FROM_SDK + KOALA_WRAPPER_PATH_FROM_SDK, + RRCORD_COMPILE_NODE } from '../pre_define'; import { PluginDriver, PluginHook } from '../plugins/plugins_driver'; import { @@ -31,6 +32,7 @@ import { OHOS_MODULE_TYPE } from '../types'; import { Logger } from '../logger'; +import { CompileSingleData } from '../record_time_mem'; process.on('message', (message: { taskList: CompileFileInfo[]; @@ -52,6 +54,8 @@ process.on('message', (message: { for (const fileInfo of taskList) { let errorStatus = false; try { + let compileSingleData = new CompileSingleData(fileInfo.filePath, buildConfig.recordType); + compileSingleData.record(RRCORD_COMPILE_NODE.SOURCE_NODE); ensurePathExists(fileInfo.abcFilePath); const source = fs.readFileSync(fileInfo.filePath).toString(); @@ -67,9 +71,11 @@ process.on('message', (message: { arktsGlobal.filePath = fileInfo.filePath; arktsGlobal.config = arkts.Config.create(ets2pandaCmd).peer; + compileSingleData.record(RRCORD_COMPILE_NODE.PROGRAM_NODE, RRCORD_COMPILE_NODE.SOURCE_NODE); arktsGlobal.compilerContext = arkts.Context.createFromString(source); PluginDriver.getInstance().getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); + compileSingleData.record(RRCORD_COMPILE_NODE.PARSE_NODE, RRCORD_COMPILE_NODE.PROGRAM_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer); if (buildConfig.aliasConfig?.size > 0) { @@ -80,10 +86,11 @@ process.on('message', (message: { PluginDriver.getInstance().getPluginContext().setArkTSAst(transformAst); } PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.PARSE_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer); if (buildConfig.hasMainModule && (buildConfig.byteCodeHar || buildConfig.moduleType === OHOS_MODULE_TYPE.SHARED)) { + compileSingleData.record(RRCORD_COMPILE_NODE.DECLGEN_NODE); let filePathFromModuleRoot: string = path.relative(buildConfig.moduleRootPath, fileInfo.filePath); let declEtsOutputPath: string = changeFileExtension( path.join(buildConfig.declgenV2OutPath as string, buildConfig.packageName, filePathFromModuleRoot), @@ -93,11 +100,15 @@ process.on('message', (message: { // Generate 1.2 declaration files(a temporary solution while binary import not pushed) arkts.generateStaticDeclarationsFromContext(declEtsOutputPath); + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.DECLGEN_NODE); } + compileSingleData.record(RRCORD_COMPILE_NODE.CHECK_NODE); PluginDriver.getInstance().runPluginHook(PluginHook.CHECKED); - + compileSingleData.record(RRCORD_COMPILE_NODE.BIN_NODE, RRCORD_COMPILE_NODE.CHECK_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED, arktsGlobal.compilerContext.peer); + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.BIN_NODE); + compileSingleData.writeSumSingle(path.dirname(fileInfo.abcFilePath)); } catch (error) { errorStatus = true; if (error instanceof Error) { diff --git a/ets2panda/driver/build_system/src/build/declgen_worker.ts b/ets2panda/driver/build_system/src/build/declgen_worker.ts index 872eb49db1761b085a6db34df3b4e6f48249a49f..a781f9f01268617c2911091d3be56f8b5fde3d1a 100644 --- a/ets2panda/driver/build_system/src/build/declgen_worker.ts +++ b/ets2panda/driver/build_system/src/build/declgen_worker.ts @@ -22,9 +22,11 @@ import { changeFileExtension, ensurePathExists } from '../utils'; import { DECL_ETS_SUFFIX, TS_SUFFIX, - KOALA_WRAPPER_PATH_FROM_SDK + KOALA_WRAPPER_PATH_FROM_SDK, + RRCORD_COMPILE_NODE } from '../pre_define'; import { PluginDriver, PluginHook } from '../plugins/plugins_driver'; +import { CompileSingleData } from '../record_time_mem'; process.on('message', (message: { taskList: CompileFileInfo[]; @@ -48,6 +50,8 @@ process.on('message', (message: { for (const fileInfo of taskList) { let errorStatus = false; try { + let compileSingleData = new CompileSingleData(fileInfo.filePath, buildConfig.recordType); + compileSingleData.record(RRCORD_COMPILE_NODE.SOURCE_NODE); const source = fs.readFileSync(fileInfo.filePath, 'utf8'); let moduleInfo = moduleInfosMap.get(fileInfo.packageName)!; let filePathFromModuleRoot: string = path.relative(moduleInfo.moduleRootPath, fileInfo.filePath); @@ -76,20 +80,26 @@ process.on('message', (message: { fileInfo.arktsConfigFile, fileInfo.filePath ]).peer; + compileSingleData.record(RRCORD_COMPILE_NODE.PROGRAM_NODE, RRCORD_COMPILE_NODE.SOURCE_NODE); arktsGlobal.compilerContext = arkts.Context.createFromString(source); pluginDriver.getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); + compileSingleData.record(RRCORD_COMPILE_NODE.PARSE_NODE, RRCORD_COMPILE_NODE.PROGRAM_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer, true); let ast = arkts.EtsScript.fromContext(); + compileSingleData.record(RRCORD_COMPILE_NODE.UI1_NODE, RRCORD_COMPILE_NODE.PARSE_NODE); pluginDriver.getPluginContext().setArkTSAst(ast); pluginDriver.runPluginHook(PluginHook.PARSED); + compileSingleData.record(RRCORD_COMPILE_NODE.CHECK_NODE, RRCORD_COMPILE_NODE.UI1_NODE); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer, true); + compileSingleData.record(RRCORD_COMPILE_NODE.UI2_NODE, RRCORD_COMPILE_NODE.CHECK_NODE); ast = arkts.EtsScript.fromContext(); pluginDriver.getPluginContext().setArkTSAst(ast); pluginDriver.runPluginHook(PluginHook.CHECKED); + compileSingleData.record(RRCORD_COMPILE_NODE.DECLGEN_NODE, RRCORD_COMPILE_NODE.UI2_NODE); arkts.generateTsDeclarationsFromContext( declEtsOutputPath, @@ -98,7 +108,9 @@ process.on('message', (message: { false ); // Generate 1.0 declaration files & 1.0 glue code logger.printInfo('declaration files generated'); - + compileSingleData.record(RRCORD_COMPILE_NODE.END_NODE, RRCORD_COMPILE_NODE.DECLGEN_NODE); + let filePath = path.join(buildConfig.cachePath, fileInfo.packageName) + compileSingleData.writeSumSingle(filePath, '_decl'); process.send({ success: true, filePath: fileInfo.filePath }); } catch (error) { errorStatus = true; 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 40285b662ba7b611663787ed9ed7abc770e89fc8..3b742dbd5c706ae5784625a02cf52d6409971e8f 100644 --- a/ets2panda/driver/build_system/src/init/process_build_config.ts +++ b/ets2panda/driver/build_system/src/init/process_build_config.ts @@ -36,8 +36,10 @@ import { ErrorCode } from '../error_code'; import { BuildConfig, BUILD_MODE, + RECORD_TYPE, AliasConfig } from '../types'; +import { RecordTimeMem } from '../record_time_mem'; export function processBuildConfig(projectConfig: BuildConfig): BuildConfig { let buildConfig: BuildConfig = { @@ -56,6 +58,9 @@ export function processBuildConfig(projectConfig: BuildConfig): BuildConfig { initBuildEnv(buildConfig); initKoalaWrapper(buildConfig); PluginDriver.getInstance().initPlugins(buildConfig); + buildConfig.recordType = buildConfig.recordType ?? RECORD_TYPE.DEFAULT_TYPE; + RecordTimeMem.getInstance().initRecordType(buildConfig.recordType); + initAliasConfig(buildConfig); initInteropSDKInfo(buildConfig); return buildConfig; diff --git a/ets2panda/driver/build_system/src/pre_define.ts b/ets2panda/driver/build_system/src/pre_define.ts index 3879de18ee97353a583f08448cd97cf22a7f0c05..34c3feee546d07e8393f49c0fdd3dde06778c247 100644 --- a/ets2panda/driver/build_system/src/pre_define.ts +++ b/ets2panda/driver/build_system/src/pre_define.ts @@ -41,6 +41,23 @@ export const DEFAULT_WOKER_NUMS: number = 4; export const ETS_1_1 = 'ets1.1'; export const ETS_1_1_INTEROP = 'ets1.1interop'; +export enum RECORD_COMPILE_TYPE { + RUN_TYPE = 'run', + DELC_TYPE = 'Declaration', +} + +export enum RRCORD_COMPILE_NODE { + SOURCE_NODE = 'source', + PARSE_NODE = 'parse', + PROGRAM_NODE= 'program', + UI1_NODE = 'ui1', + CHECK_NODE = 'checker', + UI2_NODE = 'ui2', + BIN_NODE = 'bin', + DECLGEN_NODE = 'declgen', + LOWER_NODE = 'lower', + END_NODE = '', +} export const sdkConfigPrefix = 'ohos|system|kit|arkts'; export const NATIVE_MODULE: Set = new Set( ['system.app', 'ohos.app', 'system.router', 'system.curves', 'ohos.curves', 'system.matrix4', 'ohos.matrix4']); diff --git a/ets2panda/driver/build_system/src/record_time_mem.ts b/ets2panda/driver/build_system/src/record_time_mem.ts new file mode 100644 index 0000000000000000000000000000000000000000..aaa794a809636ae1db79d5636f9258aa882821b5 --- /dev/null +++ b/ets2panda/driver/build_system/src/record_time_mem.ts @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as fs from 'fs'; +import path from 'path'; +import { RECORD_TYPE } from './types' + +export class TimeMemData { + public startTime: number = 0; + public endtime: number = 0; + public time: number = 0; + public startMem: number = 0; + public endMem:number = 0; + public mem: number = 0; +} + +export class SingleData { + public time: number = 0; + public mem: number = 0; +} + +export class CompileSingleData { + private timeMemMap: Map; + private totalTime: number = 0; + private startTime: number = 0; + private startMem: number = 0; + private file: string = ''; + private recordType: RECORD_TYPE; + + constructor(file: string, recordType?: RECORD_TYPE) { + this.file = file; + this.timeMemMap = new Map(); + this.recordType = recordType ?? RECORD_TYPE.DEFAULT_TYPE; + } + + public record(startKey: string, lastEndKey: string = '') { + if (this.recordType == RECORD_TYPE.DEFAULT_TYPE) { + return; + } + let currentTime = new Date().getTime(); + let currentMem = process.memoryUsage.rss(); + let tmp: SingleData | undefined = this.timeMemMap.get(lastEndKey); + if (tmp) { + tmp.time = currentTime - this.startTime; + tmp.mem = (currentMem > this.startMem) ? (currentMem- this.startMem) : 0; ; + this.timeMemMap.set(lastEndKey, tmp); + } + + if (startKey == '') { + return; + } + + let tmp1: SingleData | undefined = this.timeMemMap.get(startKey); + if (tmp1 == undefined) { + this.startTime = currentTime; + this.startMem = currentMem; + let data: SingleData = new SingleData(); + data.time = 0; + data.mem = 0; + this.timeMemMap.set(startKey, data); + } + } + + writeSumSingle(cachePath: string, deputyName: string = '') { + if (this.recordType == RECORD_TYPE.DEFAULT_TYPE) { + return; + } + const csvData: string[] = [ + "timeKey, time(ms), mem(M)" + ]; + this.timeMemMap.forEach((v: SingleData, k: string) => { + let element = `${k}` +', ' + `${v.time}` + 'ms' + ', ' + `${Math.round(v.mem / 1024 / 1024)}` + 'M' ; + csvData.push(element); + }); + let name = path.basename(this.file) + let currentExt = path.extname(name) + let fileWithoutExt = name.substring(0, name.lastIndexOf(currentExt)); + let fileName = `${fileWithoutExt}`+ deputyName +'_time_mem.csv'; + let filePath = path.join(cachePath, fileName); + csvData.forEach(row => { + fs.appendFileSync(filePath, `${row}\n`); + }); + } +} + + +export class RecordTimeMem { + private static instance: RecordTimeMem | undefined; + private compileType: string = ''; + private memLow: number = 0; + private memHigh: number = 0; + private timeMemMap: Map; + private recordType: RECORD_TYPE = RECORD_TYPE.DEFAULT_TYPE; + + public static getInstance(): RecordTimeMem { + if (!RecordTimeMem.instance) { + RecordTimeMem.instance = new RecordTimeMem(); + } + return RecordTimeMem.instance; + } + + private constructor() { + this.memLow = process.memoryUsage.rss(); + this.timeMemMap = new Map(); + } + + public setCompileType(type: string) { + this.compileType = type; + } + + public initRecordType(recordType: RECORD_TYPE) { + this.recordType = recordType; + } + + public start(timeKey: string) { + if (this.recordType == RECORD_TYPE.DEFAULT_TYPE) { + return; + } + let currentTime = new Date().getTime(); + let currentMem = process.memoryUsage.rss(); + let tmp: TimeMemData | undefined = this.timeMemMap.get(timeKey); + if (tmp) { + tmp.startTime = currentTime; + tmp.startMem = currentMem; + this.timeMemMap.set(timeKey, tmp); + } else { + let data: TimeMemData = new TimeMemData(); + data.startTime = currentTime; + data.endMem = currentMem; + this.timeMemMap.set(timeKey, data); + } + this.recordMem(); + } + + public end(timeKey: string) { + if (this.recordType == RECORD_TYPE.DEFAULT_TYPE) { + return; + } + let currentTime = new Date().getTime(); + let currentMem = process.memoryUsage.rss(); + let tmp: TimeMemData | undefined = this.timeMemMap.get(timeKey); + if (tmp) { + tmp.endtime = currentTime; + tmp.endMem = currentMem; + tmp.time = tmp.endtime - tmp.startTime; + tmp.mem = (tmp.endMem > tmp.startMem) ? (tmp.endMem - tmp.startMem) : 0; + this.timeMemMap.set(timeKey, tmp); + } + this.recordMem(); + } + + + private recordMem() { + let rss: number = process.memoryUsage.rss(); + if (rss < this.memLow) { + this.memLow = rss; + } + if (rss > this.memHigh) { + this.memHigh = rss; + } + } + + writeDataCsv(filePath: string, data: any[]) { + const content = data.map(row => { + return Object.values(row).join(','); + }).join('\n'); + fs.writeFile(filePath, content, (err) => { + if (err) { + console.error('Error writing file:', err); + } + }); + } + + writeSum(cachePath: string) { + if (this.recordType == RECORD_TYPE.DEFAULT_TYPE) { + return; + } + const csvData: any[] = []; + csvData.push({ timeKey: `memory low`, time: 'undefined', mem: `${Math.round(this.memLow / 1024 / 1024)}` + 'M' }); + csvData.push({ timeKey: `memory high`, time: 'undefined', mem: `${Math.round(this.memHigh / 1024 / 1024)}` + 'M' }); + csvData.push({ timeKey: `timeKey`, time: `time` + '(ms)', mem: `mem` + '(M)' }); + this.timeMemMap.forEach((v: TimeMemData, k: string) => { + let element = { timeKey: `${k}`, time: `${v.time}` + 'ms', mem: `${Math.round(v.mem / 1024 / 1024)}` + 'M' }; + csvData.push(element); + }) + let fileName = `${this.compileType}`+'_time_mem.csv'; + let filePath = path.join(cachePath, fileName); + this.writeDataCsv(filePath, csvData); + } +} diff --git a/ets2panda/driver/build_system/src/types.ts b/ets2panda/driver/build_system/src/types.ts index d3012e409640de9081b730e1b63a49e4feae6bf5..8245e13fdc765bc7b4ff518bfe9734f86f85fdad 100644 --- a/ets2panda/driver/build_system/src/types.ts +++ b/ets2panda/driver/build_system/src/types.ts @@ -12,6 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +export enum RECORD_TYPE { + DEFAULT_TYPE = 'OFF', + ON_TYPE = 'ON', +} export enum BUILD_MODE { DEBUG = 'Debug', @@ -48,6 +52,7 @@ export interface BuildBaseConfig { arktsGlobal: ArkTSGlobal; maxWorkers?: number; isBuildConfigModified?: boolean; + recordType?: RECORD_TYPE; } export interface ArkTSGlobal { diff --git a/ets2panda/driver/build_system/test/ut/base_modeTest/base_mode.test.ts b/ets2panda/driver/build_system/test/ut/base_modeTest/base_mode.test.ts index 96440a8124c1466d3c0bdfb1e49845a2c05923bf..51408f6663ceed8c18c897e42bbcf6354fa8d392 100755 --- a/ets2panda/driver/build_system/test/ut/base_modeTest/base_mode.test.ts +++ b/ets2panda/driver/build_system/test/ut/base_modeTest/base_mode.test.ts @@ -14,7 +14,7 @@ */ import { BaseMode } from '../../../src/build/base_mode'; -import { BuildConfig, BUILD_TYPE, BUILD_MODE, OHOS_MODULE_TYPE, ModuleInfo, ES2PANDA_MODE } from '../../../src/types'; +import { BuildConfig, BUILD_TYPE, BUILD_MODE, OHOS_MODULE_TYPE, ModuleInfo, ES2PANDA_MODE, RECORD_TYPE } from '../../../src/types'; import { BuildMode } from '../../../src/build/build_mode'; import { ErrorCode, @@ -22,6 +22,7 @@ import { import cluster, { Cluster, } from 'cluster'; +import { RecordTimeMem } from '../../../src/record_time_mem'; interface Job { id: string; @@ -62,6 +63,8 @@ jest.mock('os', () => ({ beforeEach(() => { jest.clearAllMocks(); process.exit = jest.fn() as any; + RecordTimeMem.getInstance().initRecordType(RECORD_TYPE.ON_TYPE); + RecordTimeMem.getInstance().setCompileType("run"); }); beforeAll(() => { @@ -1783,7 +1786,8 @@ function test_declgen_method() { Es2pandaContextState: { ES2PANDA_STATE_PARSED: 'parsed', ES2PANDA_STATE_CHECKED: 'checked' }, generateTsDeclarationsFromContext: jest.fn(), destroyConfig: jest.fn() }, - arktsGlobal: { es2panda: { _DestroyContext: jest.fn() } } + arktsGlobal: { es2panda: { _DestroyContext: jest.fn() } }, + recordType: "ON" }; const Logger = require('../../../src/logger').Logger; const PluginDriver = require('../../../src/plugins/plugins_driver').PluginDriver; diff --git a/ets2panda/driver/build_system/test/ut/compile_WorkerTest/compile_worker.test.ts b/ets2panda/driver/build_system/test/ut/compile_WorkerTest/compile_worker.test.ts index 7530394c7fc6803c60db29d37e312428a63823cd..4a33ba7a69e869e196d2ae281defb5304e3824ad 100755 --- a/ets2panda/driver/build_system/test/ut/compile_WorkerTest/compile_worker.test.ts +++ b/ets2panda/driver/build_system/test/ut/compile_WorkerTest/compile_worker.test.ts @@ -43,7 +43,19 @@ jest.mock('../../../src/logger', () => { }); jest.mock('../../../src/pre_define', () => ({ DECL_ETS_SUFFIX: '.d.ets', - KOALA_WRAPPER_PATH_FROM_SDK: 'koala' + KOALA_WRAPPER_PATH_FROM_SDK: 'koala', + RRCORD_COMPILE_NODE: { + SOURCE_NODE: 'source', + PARSE_NODE: 'parse', + PROGRAM_NODE: 'program', + UI1_NODE: 'ui1', + CHECK_NODE: 'checker', + UI2_NODE: 'ui2', + BIN_NODE: 'bin', + DECLGEN_NODE: 'declgen', + LOWER_NODE: 'lower', + END_NODE: '' + } })); jest.mock('/sdk/koala', () => ({ arkts: fakeArkts, diff --git a/ets2panda/driver/build_system/test/ut/compile_thread_workerTest/compile_thread_worker.test.ts b/ets2panda/driver/build_system/test/ut/compile_thread_workerTest/compile_thread_worker.test.ts index 7b2783a1cbfa9a5513dcf28c169a053e69b44fb1..b52da886fe6754f66cb728cbafd83173fbca5807 100755 --- a/ets2panda/driver/build_system/test/ut/compile_thread_workerTest/compile_thread_worker.test.ts +++ b/ets2panda/driver/build_system/test/ut/compile_thread_workerTest/compile_thread_worker.test.ts @@ -47,7 +47,19 @@ jest.mock('../../../src/logger', () => { }); jest.mock('../../../src/pre_define', () => ({ DECL_ETS_SUFFIX: '.d.ets', - KOALA_WRAPPER_PATH_FROM_SDK: 'koala' + KOALA_WRAPPER_PATH_FROM_SDK: 'koala', + RRCORD_COMPILE_NODE: { + SOURCE_NODE: 'source', + PARSE_NODE: 'parse', + PROGRAM_NODE: 'program', + UI1_NODE: 'ui1', + CHECK_NODE: 'checker', + UI2_NODE: 'ui2', + BIN_NODE: 'bin', + DECLGEN_NODE: 'declgen', + LOWER_NODE: 'lower', + END_NODE: '' + } })); const fakeArkts = { diff --git a/ets2panda/driver/build_system/test/ut/declgen_workerTest/declgen_worker.test.ts b/ets2panda/driver/build_system/test/ut/declgen_workerTest/declgen_worker.test.ts index 156a15f1235efe7bf666c58761443fac8a5593df..780509ce66025abc6c6355fe7efce9e4b7a7c5b3 100755 --- a/ets2panda/driver/build_system/test/ut/declgen_workerTest/declgen_worker.test.ts +++ b/ets2panda/driver/build_system/test/ut/declgen_workerTest/declgen_worker.test.ts @@ -48,7 +48,19 @@ jest.mock('../../../src/logger', () => { jest.mock('../../../src/pre_define', () => ({ DECL_ETS_SUFFIX: '.d.ets', TS_SUFFIX: '.ts', - KOALA_WRAPPER_PATH_FROM_SDK: 'koala' + KOALA_WRAPPER_PATH_FROM_SDK: 'koala', + RRCORD_COMPILE_NODE: { + SOURCE_NODE: 'source', + PARSE_NODE: 'parse', + PROGRAM_NODE: 'program', + UI1_NODE: 'ui1', + CHECK_NODE: 'checker', + UI2_NODE: 'ui2', + BIN_NODE: 'bin', + DECLGEN_NODE: 'declgen', + LOWER_NODE: 'lower', + END_NODE: '' + } })); const fakeArkts = {