From 934aad1c7ebb487a42281461bf09fa2f807f191d Mon Sep 17 00:00:00 2001 From: kleene Date: Tue, 19 Aug 2025 15:57:55 +0800 Subject: [PATCH] fix compile failed Issue: ICTO9H Signed-off-by: kleene Change-Id: I32e60e40acc2d201a4f18819b9c7aee0ab1da09b --- .../driver/build_system/build_build_system.py | 36 ++++++++++--------- ets2panda/driver/build_system/package.json | 2 +- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/ets2panda/driver/build_system/build_build_system.py b/ets2panda/driver/build_system/build_build_system.py index 70ac97d99d..59f2e7579f 100755 --- a/ets2panda/driver/build_system/build_build_system.py +++ b/ets2panda/driver/build_system/build_build_system.py @@ -13,12 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import argparse import os -import shutil +import time import subprocess +import shutil +import argparse import sys -import tarfile def copy_files(source_path, dest_path, is_file=False): @@ -27,29 +27,34 @@ def copy_files(source_path, dest_path, is_file=False): shutil.copy(source_path, dest_path) else: shutil.copytree(source_path, dest_path, dirs_exist_ok=True, - symlinks=True) + symlinks=True) except Exception as err: raise Exception("Copy files failed. Error: " + str(err)) from err def run_cmd(cmd, execution_path=None): proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stdin=subprocess.PIPE, - stderr=subprocess.PIPE, - cwd=execution_path) + stdin=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=execution_path) stdout, stderr = proc.communicate(timeout=300) if proc.returncode != 0: raise Exception(stderr.decode()) def build(options): - build_cmd = [options.npm, 'run', 'build'] + options.temp_dir = os.path.join(options.source_path, f"temp{time.time_ns()}") + options.build_out = os.path.join(options.temp_dir, "dist") + os.makedirs(options.temp_dir, exist_ok=True) + + build_cmd = [options.npm, 'run', 'build', '--', '--outDir', options.build_out] run_cmd(build_cmd, options.source_path) def copy_output(options): run_cmd(['rm', '-rf', options.output_path]) - copy_files(os.path.join(options.source_path, 'dist'), + + copy_files(options.build_out, os.path.join(options.output_path, 'dist')) copy_files(os.path.join(options.source_path, 'node_modules'), @@ -58,20 +63,19 @@ def copy_output(options): copy_files(os.path.join(options.source_path, 'package.json'), os.path.join(options.output_path, 'package.json'), True) + shutil.rmtree(options.temp_dir, ignore_errors=True) + def parse_args(): parser = argparse.ArgumentParser() - parser.add_argument('--npm', help='path to a npm exetuable') - parser.add_argument('--source_path', help='path to build system source') - parser.add_argument('--output_path', help='path to output') - - options = parser.parse_args() - return options + parser.add_argument('--npm', required=True, help='path to a npm executable') + parser.add_argument('--source_path', required=True, help='path to build system source') + parser.add_argument('--output_path', required=True, help='path to output') + return parser.parse_args() def main(): options = parse_args() - build(options) copy_output(options) diff --git a/ets2panda/driver/build_system/package.json b/ets2panda/driver/build_system/package.json index 9ba50d6869..bc049fc3b8 100644 --- a/ets2panda/driver/build_system/package.json +++ b/ets2panda/driver/build_system/package.json @@ -8,7 +8,7 @@ }, "main": "dist/index.js", "scripts": { - "clean": "rimraf dist", + "clean": "rimraf ${npm_config_outdir:-dist}", "build": "npm run clean && tsc", "build_debug": "npm run clean && tsc --sourceMap", "demo_entry1.2_hsp1.2:gen_abc": "npm run build && node ./dist/entry.js test/e2e/demo_entry1.2_hsp1.2/build_config1.json && node ./dist/entry.js test/e2e/demo_entry1.2_hsp1.2/build_config2.json", -- Gitee