diff --git a/ets2panda/driver/build_system/README.md b/ets2panda/driver/build_system/README.md index 414e8efc043ff59b3442d22236ee37d7897808f3..667ca25c5d897c40e3a10b307808eaeeda619e87 100644 --- a/ets2panda/driver/build_system/README.md +++ b/ets2panda/driver/build_system/README.md @@ -2,6 +2,11 @@ The build system is designed to compile ArkTS1.2 source files. It takes source files and build configurations as input, compiles the source files, invokes plugins for transformation, and generates a merged bytecode file. +## env +USE_KOALA_LIBARKTS - use libarkts from koala_mirror +USE_KOALA_UI_PLUGIN - use ui-plugin from koala_mirror +USE_KOALA_MEMO_PLUGIN - use memo-plugin from koala_mirror + ## How to Run The build system has two usage scenarios: diff --git a/ets2panda/driver/build_system/src/plugins/plugins_driver.ts b/ets2panda/driver/build_system/src/plugins/plugins_driver.ts index 67203f601dcc973398d5469c3ae58a5e26159fc7..9213df98d63bc2e8fc9a040064d974c048dd9902 100644 --- a/ets2panda/driver/build_system/src/plugins/plugins_driver.ts +++ b/ets2panda/driver/build_system/src/plugins/plugins_driver.ts @@ -21,6 +21,8 @@ import { import { BuildConfig } from '../types'; import { ErrorCode } from '../error_code'; import { FileManager } from './FileManager'; +import path from 'path' +import { MEMO_PLUGIN_PATH_FROM_SDK, UI_PLUGIN_PATH_FROM_SDK } from '../pre_define'; export enum PluginHook { NEW = 'afterNew', @@ -149,11 +151,28 @@ export class PluginDriver { PluginDriver.instance = undefined; } + private initKoalaPlugins(projectConfig: BuildConfig): void { + + const uiPluginPath = path.resolve(projectConfig.buildSdkPath, UI_PLUGIN_PATH_FROM_SDK); + const memoPluginPath = path.resolve(projectConfig.buildSdkPath, MEMO_PLUGIN_PATH_FROM_SDK); + + // TODO: need change in hvigor + if (process.env.USE_KOALA_UI_PLUGIN) { + projectConfig.plugins['ArkUI'] = uiPluginPath + } + + if (process.env.USE_KOALA_MEMO_PLUGIN) { + projectConfig.plugins['ArkUI-Memo'] = memoPluginPath + } + } + public initPlugins(projectConfig: BuildConfig): void { if (!projectConfig || !projectConfig.plugins) { return; } + this.initKoalaPlugins(projectConfig) + const pluginResults: RawPlugins[] = Object.entries(projectConfig.plugins).map(([key, value]) => { try { let pluginObject = require(value as string); diff --git a/ets2panda/driver/build_system/src/pre_define.ts b/ets2panda/driver/build_system/src/pre_define.ts index bb0ef186ede0dfa3de635077af53716953280ed2..10a3dc54191d25c2133bc76de730e01c03a599f8 100644 --- a/ets2panda/driver/build_system/src/pre_define.ts +++ b/ets2panda/driver/build_system/src/pre_define.ts @@ -36,7 +36,6 @@ export enum LANGUAGE_VERSION { export const PANDA_SDK_PATH_FROM_SDK: string = './build-tools/ets2panda'; export const SYSTEM_SDK_PATH_FROM_SDK: string = './'; -export const KOALA_WRAPPER_PATH_FROM_SDK: string = './build-tools/koala-wrapper/build/lib/es2panda'; export const KIT_CONFIGS_PATH_FROM_SDK: string = '../ets1.1/build-tools/ets-loader/kit_configs'; export const DEFAULT_WOKER_NUMS: number = 4; @@ -62,3 +61,7 @@ export type Record = { [P in K]: T; }; `; +// Koala experimental variables +export const KOALA_WRAPPER_PATH_FROM_SDK: string = process.env.USE_KOALA_LIBARKTS ? './build-tools/ui2abc/libarkts/lib/libarkts.js' : './build-tools/koala-wrapper/build/lib/es2panda' +export const UI_PLUGIN_PATH_FROM_SDK: string = './build-tools/ui2abc/ui-plugin/lib/entry.js' +export const MEMO_PLUGIN_PATH_FROM_SDK: string = './build-tools/ui2abc/memo-plugin/lib/entry.js'