From c7c7d628407e8fad4158ef98b1023fab775d55c4 Mon Sep 17 00:00:00 2001 From: "Alexander Ilyenko (WX1330152)" Date: Mon, 1 Sep 2025 17:29:23 +0300 Subject: [PATCH] Add: mirror "koala_tools" --- tools/mirror.mjs | 54 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/tools/mirror.mjs b/tools/mirror.mjs index 16213a983e..c981c7f1c5 100644 --- a/tools/mirror.mjs +++ b/tools/mirror.mjs @@ -7,6 +7,9 @@ const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) const KOALA_HOME = path.resolve(path.join(__dirname, "..")) const USE_MIRROR_BUNDLE = process.env.USE_MIRROR_BUNDLE ? true : false +const arkuiPluginsRepoUrl = "https://gitee.com/openharmony/developtools_ace_ets2bundle" +const arkuiPluginsRepoPath = process.env.DEVELOPTOOLS_ACE_ETS2BUNDLE_PATH + ?? path.join(KOALA_HOME, "developtools_ace_ets2bundle") const args = process.argv.slice(2) const outPath = args[0] ?? path.join(KOALA_HOME, USE_MIRROR_BUNDLE ? "koala_tools" : "koala_mirror") @@ -21,9 +24,14 @@ const sourcesAce = [ ] const sourcesBundle = [ - "incremental", + { dst: "arkui-plugins", src: `${arkuiPluginsRepoPath}/arkui-plugins`, }, + { dst: "build-common", src: "incremental/build-common", }, + { dst: "common" , src: "incremental/common", }, + { dst: "compat" , src: "incremental/compat", }, "interop", - "ui2abc", + { dst: "libarkts", src: "ui2abc/libarkts", }, + { dst: "tests_ui", src: `${arkuiPluginsRepoPath}/arkui-plugins/test/ut/ui-plugins`, }, + { dst: "tests_memo", src: `${arkuiPluginsRepoPath}/arkui-plugins/test/ut/memo-plugins`, }, "gn", ".gitignore" ] @@ -101,18 +109,22 @@ const excludesExceptions = [ "ui2abc/libarkts/native/meson.build" ] -const packageStubs = [ +const packageStubsInAce = [ "incremental/compiler-plugin" ] +const packageStubs = USE_MIRROR_BUNDLE ? [] : packageStubsInAce + const optionalPackages = [ "@koalaui/compiler-plugin" ] -const optionalPackagesDependees = [ +const optionalPackagesDependeesInAce = [ "ui2abc/tests-memo" ] +const optionalPackagesDependees = USE_MIRROR_BUNDLE ? [] : optionalPackagesDependeesInAce + function main() { if (!USE_MIRROR_BUNDLE) { const genGniMirrorScript = path.join(__dirname, "utils", "gni", "gen_gni_mirror.sh") @@ -134,12 +146,40 @@ function main() { const matches = (file, patterns) => patterns.some(p => file.endsWith(p) || file.match(`/${p}/`)) const allExcludes = USE_MIRROR_BUNDLE ? excludesInBundle.concat(packageStubs) : excludesInAce.concat(packageStubs) + if (USE_MIRROR_BUNDLE && ( + !fs.existsSync(arkuiPluginsRepoPath) + || !fs.lstatSync(arkuiPluginsRepoPath).isDirectory() + )) { + fs.mkdirSync(arkuiPluginsRepoUrl, { + recursive: true, + }) + execSync(`git clone ${arkuiPluginsRepoUrl} ${arkuiPluginsRepoPath}`, { + stdio: 'inherit', cwd: KOALA_HOME + }) + } + sources.forEach(project => { - const src = path.join(KOALA_HOME, project) - const dst = path.join(outPath, project) + const isProjectString = typeof(project) == "string" + + let dst + if (isProjectString) { + dst = path.join(outPath, project) + } else { + dst = path.join(outPath, project.dst) + } + + let src + if (isProjectString) { + src = path.join(KOALA_HOME, project) + } else { + src = path.join(KOALA_HOME, project.src) + if (!fs.existsSync(src)) { + src = project.src + } + } if (fs.lstatSync(src).isDirectory()) { - fs.cpSync(path.join(KOALA_HOME, project), path.join(outPath, project), { + fs.cpSync(src, dst, { force: true, recursive: true, filter: src => !matches(src, allExcludes) || matches(src, excludesExceptions) -- Gitee