From c06dad51fc9272d2e077c7d2b5206ac6c5c2ff53 Mon Sep 17 00:00:00 2001 From: Korobeinikov Evgeny Date: Sat, 5 Jul 2025 19:03:07 +0300 Subject: [PATCH] Using koala_mirror plugins and libarkts Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICM9QP Signed-off-by: Korobeinikov Evgeny Change-Id: I697bf5f0b08801de8a3601b5df7c25e6f73bd88f --- ets2panda/driver/build_system/README.md | 5 +++++ .../src/plugins/plugins_driver.ts | 19 +++++++++++++++++++ .../driver/build_system/src/pre_define.ts | 5 ++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ets2panda/driver/build_system/README.md b/ets2panda/driver/build_system/README.md index 414e8efc04..667ca25c5d 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 67203f601d..9213df98d6 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 bb0ef186ed..10a3dc5419 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' -- Gitee