diff --git a/ets2panda/driver/build_system/src/build/base_mode.ts b/ets2panda/driver/build_system/src/build/base_mode.ts index 5d374555e638439d06cb2e6de8002d8cfb67d889..e8ac0aecfb927c81278564aa638c2767f35266ea 100644 --- a/ets2panda/driver/build_system/src/build/base_mode.ts +++ b/ets2panda/driver/build_system/src/build/base_mode.ts @@ -174,13 +174,13 @@ export abstract class BaseMode { arktsGlobal.compilerContext = arkts.Context.createFromString(source); PluginDriver.getInstance().getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, true); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer, true); let ast = arkts.EtsScript.fromContext(); PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, true); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer, true); ast = arkts.EtsScript.fromContext(); PluginDriver.getInstance().getPluginContext().setArkTSAst(ast); @@ -240,21 +240,21 @@ export abstract class BaseMode { arktsGlobal.compilerContext = arkts.Context.createFromString(source); PluginDriver.getInstance().getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED); + 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); + 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); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED, arktsGlobal.compilerContext.peer); this.logger.printInfo('es2panda bin generated'); } catch (error) { errorStatus = true; @@ -1225,26 +1225,6 @@ export abstract class BaseMode { }); } - private updateDependantJobs(jobId: string, processingJobs: Set, jobs: Record, queues: Queues): void { - finishedJob.push(jobId); - processingJobs.delete(jobId); - const completedJob = jobs[jobId]; - completedJob.dependants.forEach(depJobId => { - const depJob = jobs[depJobId]; - // During incremental compilation, the dependants task does not necessarily exist - if (!depJob) { - return; - } - const depIndex = depJob.dependencies.indexOf(jobId); - if (depIndex !== -1) { - depJob.dependencies.splice(depIndex, 1); - if (depJob.dependencies.length === 0) { - this.addJobToQueues(depJob, queues); - } - } - }); - } - private assignTaskToIdleWorker( workerInfo: WorkerInfo, queues: Queues, 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 c8aaed5662e3e462af6e2e22e0c0fcadea4f56f4..db45e16117e5c4535111ba8f004b37fa6a58daab 100644 --- a/ets2panda/driver/build_system/src/build/compile_thread_worker.ts +++ b/ets2panda/driver/build_system/src/build/compile_thread_worker.ts @@ -36,34 +36,33 @@ import { ErrorCode } from '../error_code'; const { workerId } = workerData; function compileAbc(jobInfo: JobInfo): void { - let config = jobInfo.buildConfig as BuildConfig; - Logger.getInstance(config); - PluginDriver.getInstance().initPlugins(config); - const koalaWrapperPath = path.resolve(config.buildSdkPath, KOALA_WRAPPER_PATH_FROM_SDK); + let buildConfig = jobInfo.buildConfig as BuildConfig; + Logger.getInstance(buildConfig); + PluginDriver.getInstance().initPlugins(buildConfig); + const koalaWrapperPath = path.resolve(buildConfig.buildSdkPath, KOALA_WRAPPER_PATH_FROM_SDK); let { arkts, arktsGlobal } = require(koalaWrapperPath); - const isDebug = config.buildMode === BUILD_MODE.DEBUG; + const isDebug = buildConfig.buildMode === BUILD_MODE.DEBUG; let errorStatus = false; - try { - let fileInfo = jobInfo.compileFileInfo; - ensurePathExists(fileInfo.abcFilePath); - - const ets2pandaCmd = [ - '_', '--extension', 'ets', - '--arktsconfig', fileInfo.arktsConfigFile, - '--output', fileInfo.abcFilePath, - ]; + let fileInfo = jobInfo.compileFileInfo; + ensurePathExists(fileInfo.abcFilePath); - if (isDebug) { - ets2pandaCmd.push('--debug-info'); - } - ets2pandaCmd.push(fileInfo.filePath); + const ets2pandaCmd = [ + '_', '--extension', 'ets', + '--arktsconfig', fileInfo.arktsConfigFile, + '--output', fileInfo.abcFilePath, + ]; - let config = arkts.Config.create(ets2pandaCmd).peer; - arktsGlobal.config = config; + if (isDebug) { + ets2pandaCmd.push('--debug-info'); + } + ets2pandaCmd.push(fileInfo.filePath); - let context = arkts.Context.createCacheContextFromFile(config, fileInfo.filePath, jobInfo.globalContextPtr, false).peer; + let config = arkts.Config.create(ets2pandaCmd).peer; + arktsGlobal.config = config; + let context = arkts.Context.createCacheContextFromFile(config, fileInfo.filePath, jobInfo.globalContextPtr, false).peer; + try { PluginDriver.getInstance().getPluginContext().setContextPtr(context); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, context); @@ -88,7 +87,7 @@ function compileAbc(jobInfo: JobInfo): void { } finally { if (!errorStatus) { // when error occur,wrapper will destroy context. - arktsGlobal.es2panda._DestroyContext(arktsGlobal.compilerContext.peer); + arktsGlobal.es2panda._DestroyContext(context); } PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); arkts.destroyConfig(arktsGlobal.config); @@ -96,28 +95,27 @@ function compileAbc(jobInfo: JobInfo): void { } function compileExternalProgram(jobInfo: JobInfo): void { - let config = jobInfo.buildConfig as BuildConfig; - Logger.getInstance(config); - PluginDriver.getInstance().initPlugins(config); - const koalaWrapperPath = path.resolve(config.buildSdkPath, KOALA_WRAPPER_PATH_FROM_SDK); + let buildConfig = jobInfo.buildConfig as BuildConfig; + Logger.getInstance(buildConfig); + PluginDriver.getInstance().initPlugins(buildConfig); + const koalaWrapperPath = path.resolve(buildConfig.buildSdkPath, KOALA_WRAPPER_PATH_FROM_SDK); let { arkts, arktsGlobal } = require(koalaWrapperPath); - const isDebug = config.buildMode === BUILD_MODE.DEBUG; + const isDebug = buildConfig.buildMode === BUILD_MODE.DEBUG; let errorStatus = false; - try { - let fileInfo = jobInfo.compileFileInfo; - const ets2pandaCmd = ['-', '--extension', 'ets', '--arktsconfig', fileInfo.arktsConfigFile]; - - if (isDebug) { - ets2pandaCmd.push('--debug-info'); - } - ets2pandaCmd.push(fileInfo.filePath); + let fileInfo = jobInfo.compileFileInfo; + const ets2pandaCmd = ['-', '--extension', 'ets', '--arktsconfig', fileInfo.arktsConfigFile]; - let config = arkts.Config.create(ets2pandaCmd).peer; - arktsGlobal.config = config; + if (isDebug) { + ets2pandaCmd.push('--debug-info'); + } + ets2pandaCmd.push(fileInfo.filePath); - let context = arkts.Context.createCacheContextFromFile(config, fileInfo.filePath, jobInfo.globalContextPtr, true).peer; + let config = arkts.Config.create(ets2pandaCmd).peer; + arktsGlobal.config = config; + let context = arkts.Context.createCacheContextFromFile(config, fileInfo.filePath, jobInfo.globalContextPtr, true).peer; + try { PluginDriver.getInstance().getPluginContext().setContextPtr(context); arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, context); @@ -142,7 +140,7 @@ function compileExternalProgram(jobInfo: JobInfo): void { } finally { if (!errorStatus) { // when error occur,wrapper will destroy context. - arktsGlobal.es2panda._DestroyContext(arktsGlobal.compilerContext.peer); + arktsGlobal.es2panda._DestroyContext(context); } PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); arkts.destroyConfig(arktsGlobal.config); diff --git a/ets2panda/driver/build_system/src/build/compile_worker.ts b/ets2panda/driver/build_system/src/build/compile_worker.ts index 38a1fcdb596325139a0fe145d26194643394950b..fd5065c39f52a3b09ec5bb43d3dbabf314ad7064 100644 --- a/ets2panda/driver/build_system/src/build/compile_worker.ts +++ b/ets2panda/driver/build_system/src/build/compile_worker.ts @@ -70,13 +70,13 @@ process.on('message', (message: { PluginDriver.getInstance().getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer); PluginDriver.getInstance().runPluginHook(PluginHook.CHECKED); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED, arktsGlobal.compilerContext.peer); } 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 2d25e9704d485b7561a6842f3fd81cdeaf405e74..63968d0d15f648925d1c2121ed6144717caa5e27 100644 --- a/ets2panda/driver/build_system/src/build/declgen_worker.ts +++ b/ets2panda/driver/build_system/src/build/declgen_worker.ts @@ -79,13 +79,13 @@ process.on('message', (message: { arktsGlobal.compilerContext = arkts.Context.createFromString(source); pluginDriver.getPluginContext().setArkTSProgram(arktsGlobal.compilerContext.program); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, true); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, arktsGlobal.compilerContext.peer, true); let ast = arkts.EtsScript.fromContext(); pluginDriver.getPluginContext().setArkTSAst(ast); pluginDriver.runPluginHook(PluginHook.PARSED); - arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, true); + arkts.proceedToState(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, arktsGlobal.compilerContext.peer, true); ast = arkts.EtsScript.fromContext(); pluginDriver.getPluginContext().setArkTSAst(ast); diff --git a/ets2panda/driver/build_system/src/plugins/plugins_driver.ts b/ets2panda/driver/build_system/src/plugins/plugins_driver.ts index 67203f601dcc973398d5469c3ae58a5e26159fc7..2bd46fcb261b4b0b5e015660071b3f2bac3165ba 100644 --- a/ets2panda/driver/build_system/src/plugins/plugins_driver.ts +++ b/ets2panda/driver/build_system/src/plugins/plugins_driver.ts @@ -112,7 +112,7 @@ class PluginContext { } } - public getFileManager(): FileManager | undefined{ + public getFileManager(): FileManager | undefined { return this.fileManager; }