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 eef6db8d34a8b822f64c832bce713c005d754712..036f80eee987d507c09c87e13c517d0f4da56307 100644 --- a/ets2panda/driver/build_system/src/build/compile_thread_worker.ts +++ b/ets2panda/driver/build_system/src/build/compile_thread_worker.ts @@ -25,7 +25,11 @@ import { DECL_ETS_SUFFIX, KOALA_WRAPPER_PATH_FROM_SDK } from '../pre_define'; -import { PluginDriver, PluginHook } from '../plugins/plugins_driver'; +import { + PluginDriver, + PluginHook, + CompileJobInfo +} from '../plugins/plugins_driver'; import { BuildConfig, BUILD_MODE, @@ -37,6 +41,7 @@ import { Logger } from '../logger'; import { ErrorCode } from '../error_code'; +import {COMPILE_TYPE} from '../pre_define' const { workerId } = workerData; @@ -44,6 +49,9 @@ function compileAbc(jobInfo: JobInfo): void { let config = jobInfo.buildConfig as BuildConfig; Logger.getInstance(config); PluginDriver.getInstance().initPlugins(config); + const compileJobInfo = new CompileJobInfo(jobInfo.compileFileInfo.filePath, COMPILE_TYPE.COMPILE); + PluginDriver.getInstance().getPluginContext().setCompileJob(compileJobInfo); + const koalaWrapperPath = path.resolve(config.buildSdkPath, KOALA_WRAPPER_PATH_FROM_SDK); let { arkts, arktsGlobal } = require(koalaWrapperPath); const isDebug = config.buildMode === BUILD_MODE.DEBUG; @@ -116,6 +124,10 @@ function compileExternalProgram(jobInfo: JobInfo): void { let config = jobInfo.buildConfig as BuildConfig; Logger.getInstance(config); PluginDriver.getInstance().initPlugins(config); + PluginDriver.getInstance().initPlugins(config); + const compileJobInfo = new CompileJobInfo(jobInfo.compileFileInfo.filePath, COMPILE_TYPE.EXTERNAL); + PluginDriver.getInstance().getPluginContext().setCompileJob(compileJobInfo); + const koalaWrapperPath = path.resolve(config.buildSdkPath, KOALA_WRAPPER_PATH_FROM_SDK); let { arkts, arktsGlobal } = require(koalaWrapperPath); const isDebug = config.buildMode === BUILD_MODE.DEBUG; @@ -184,4 +196,4 @@ parentPort?.on('message', (msg) => { } else if (msg.type === 'EXIT') { process.exit(0); } -}); +}); \ No newline at end of file diff --git a/ets2panda/driver/build_system/src/plugins/plugins_driver.ts b/ets2panda/driver/build_system/src/plugins/plugins_driver.ts index 67203f601dcc973398d5469c3ae58a5e26159fc7..38f58329783579954ea83637d150a8121cc5a1fd 100644 --- a/ets2panda/driver/build_system/src/plugins/plugins_driver.ts +++ b/ets2panda/driver/build_system/src/plugins/plugins_driver.ts @@ -72,6 +72,7 @@ class PluginContext { private projectConfig: object | undefined; private fileManager: FileManager | undefined; private contextPtr: number | undefined; + private compileJobInfo: CompileJobInfo | undefined; constructor() { this.ast = undefined; @@ -79,6 +80,7 @@ class PluginContext { this.projectConfig = undefined; this.fileManager = undefined; this.contextPtr = undefined; + this.compileJobInfo = undefined; } public setArkTSAst(ast: object): void { @@ -112,7 +114,7 @@ class PluginContext { } } - public getFileManager(): FileManager | undefined{ + public getFileManager(): FileManager | undefined { return this.fileManager; } @@ -121,7 +123,15 @@ class PluginContext { } public getContextPtr(): number | undefined { - return this.contextPtr; + return this.contextPtr; + } + + public setCompileJob(compileJobInfo: CompileJobInfo): void { + this.compileJobInfo = compileJobInfo; + } + + public getCompileJob(compileJobInfo: CompileJobInfo): CompileJobInfo | undefined { + return this.compileJobInfo; } } @@ -191,7 +201,7 @@ export class PluginDriver { this.context.setFileManager(projectConfig); } - private getPlugins(hook: PluginHook) : PluginExecutor[] | undefined { + private getPlugins(hook: PluginHook): PluginExecutor[] | undefined { if (!this.sortedPlugins.has(hook)) { const sortedPlugins: PluginExecutor[] = this.getSortedPlugins(hook); if (sortedPlugins.length === 0) { @@ -249,4 +259,14 @@ export class PluginDriver { public getPluginContext(): PluginContext { return this.context; } +} + +export class CompileJobInfo { + private filePath: string; + private compileType: string; + + constructor(filePath:string,compileType: string) { + this.filePath = filePath; + this.compileType = compileType; + } } \ No newline at end of file diff --git a/ets2panda/driver/build_system/src/pre_define.ts b/ets2panda/driver/build_system/src/pre_define.ts index 0b42278bebc8a67326b381d9b4d7f303f241ec6c..b68fc087cdb1cec99e8d104bf82cae2abed6e3df 100644 --- a/ets2panda/driver/build_system/src/pre_define.ts +++ b/ets2panda/driver/build_system/src/pre_define.ts @@ -38,4 +38,9 @@ export const KOALA_WRAPPER_PATH_FROM_SDK: string = './build-tools/koala-wrapper/ export const DEFAULT_WOKER_NUMS: number = 4; export const ETS_1_1 = 'ets1.1'; -export const ETS_1_1_INTEROP = 'ets1.1interop'; \ No newline at end of file +export const ETS_1_1_INTEROP = 'ets1.1interop'; + +export enum COMPILE_TYPE { + COMPILE = 'compile', + EXTERNAL = 'external' +} \ No newline at end of file