From dca1fd7fd5dba5ea31b37706184d837ea9572029 Mon Sep 17 00:00:00 2001 From: zgy-ian Date: Sat, 11 Sep 2021 17:32:12 +0800 Subject: [PATCH] Modify the ts2abc compilation issue Signed-off-by: zgy-ian --- ts2panda/BUILD.gn | 8 ++++++++ ts2panda/scripts/run.py | 16 ++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ts2panda/BUILD.gn b/ts2panda/BUILD.gn index 9b3a5ec493..d55f7e716f 100755 --- a/ts2panda/BUILD.gn +++ b/ts2panda/BUILD.gn @@ -25,6 +25,13 @@ ohos_copy("ts2abc_src") { module_install_name = "" } +ohos_copy("node_modules") { + sources = [ rebase_path("${node_modules}") ] + + outputs = [ target_out_dir + "/node_modules" ] + module_install_name = "" +} + ohos_copy("tsconfig_json") { sources = [ "${ts2abc_root}/tsconfig.json" ] @@ -65,6 +72,7 @@ ark_gen_file("ts2abc_irnodes_ts") { action("npm_run_build") { visibility = [ ":*" ] deps = [ + "$ts2abc_root:node_modules", "$ts2abc_root:ts2abc_diagnostic_ts", "$ts2abc_root:ts2abc_irnodes_ts", "$ts2abc_root:ts2abc_src", diff --git a/ts2panda/scripts/run.py b/ts2panda/scripts/run.py index 9a25349547..bb33dc1377 100755 --- a/ts2panda/scripts/run.py +++ b/ts2panda/scripts/run.py @@ -19,6 +19,7 @@ Description: Compile ark front-end code with tsc """ import os +import sys import subprocess import argparse import platform @@ -74,10 +75,8 @@ def node_modules(options): def npm_run_build(options): plat_form = options.platform - node_modules_dir = os.path.join(options.dist_dir, 'node_modules') - tsc = os.path.join(node_modules_dir, "typescript/bin/tsc") - - os.environ["NODE_PATH"] = node_modules_dir + os.chdir(options.dist_dir) + tsc = "node_modules/typescript/bin/tsc" if plat_form == "linux": cmd = [tsc, '-b', 'src'] @@ -90,8 +89,13 @@ def npm_run_build(options): run_command(cmd, options.dist_dir) -if __name__ == "__main__": +def main(): ARGS = parse_args() set_env(ARGS.node) - node_modules(ARGS) + if not os.path.exists(os.path.join(ARGS.dist_dir, "node_modules")): + node_modules(ARGS) npm_run_build(ARGS) + + +if __name__ == "__main__": + sys.exit(main()) -- Gitee