diff --git a/ts2panda/BUILD.gn b/ts2panda/BUILD.gn index 0e47d53baa677dcbf88599f359a0de33270bcfe7..1e0c7adb5473c5efca668025717bbd36c914338e 100755 --- a/ts2panda/BUILD.gn +++ b/ts2panda/BUILD.gn @@ -35,10 +35,23 @@ group("ts2abc_src") { } } +action("npm_install_tsc") { + deps = [ "//third_party/typescript:build_typescript" ] + script = "npm_install_tsc.py" + args = [ + rebase_path("${root_out_dir}/obj/third_party/typescript/typescript-4.2.3-r2.tgz"), + rebase_path("//prebuilts/build-tools/common/ts2abc"), + rebase_path(get_path_info("./", "abspath")), + rebase_path("${target_out_dir}/${target_name}.stamp"), + ] + outputs = [ "${target_out_dir}/${target_name}.stamp" ] +} + ohos_copy("node_modules") { sources = [ rebase_path("${node_modules}") ] outputs = [ target_out_dir + "/node_modules" ] module_install_name = "" + deps = [ ":npm_install_tsc" ] } ohos_copy("config_files") { @@ -54,8 +67,7 @@ ohos_copy("config_files") { } ohos_copy("ts2abc_deps") { - sources = - [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ] + sources = [ "${root_out_dir}/obj/third_party/typescript/typescript-4.2.3-r2.tgz" ] outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] module_source_dir = target_out_dir + "/$target_name" @@ -63,11 +75,11 @@ ohos_copy("ts2abc_deps") { license_file = "//third_party/typescript/LICENSE" part_name = "ets_frontend" subsystem_name = "arkcompiler" + deps = [ "//third_party/typescript:build_typescript" ] } ohos_copy("ts2abc_deps_ets") { - sources = - [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ] + sources = [ "${root_out_dir}/obj/third_party/typescript/typescript-4.2.3-r2.tgz" ] outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] module_source_dir = target_out_dir + "/$target_name" @@ -75,11 +87,11 @@ ohos_copy("ts2abc_deps_ets") { license_file = "//third_party/typescript/LICENSE" part_name = "ets_frontend" subsystem_name = "arkcompiler" + deps = [ "//third_party/typescript:build_typescript" ] } ohos_copy("ts2abc_deps_win") { - sources = - [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ] + sources = [ "${root_out_dir}/obj/third_party/typescript/typescript-4.2.3-r2.tgz" ] outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] module_source_dir = target_out_dir + "/$target_name" @@ -87,11 +99,11 @@ ohos_copy("ts2abc_deps_win") { license_file = "//third_party/typescript/LICENSE" part_name = "ets_frontend" subsystem_name = "arkcompiler" + deps = [ "//third_party/typescript:build_typescript" ] } ohos_copy("ts2abc_deps_win_ets") { - sources = - [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ] + sources = [ "${root_out_dir}/obj/third_party/typescript/typescript-4.2.3-r2.tgz" ] outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] module_source_dir = target_out_dir + "/$target_name" @@ -99,11 +111,11 @@ ohos_copy("ts2abc_deps_win_ets") { license_file = "//third_party/typescript/LICENSE" part_name = "ets_frontend" subsystem_name = "arkcompiler" + deps = [ "//third_party/typescript:build_typescript" ] } ohos_copy("ts2abc_deps_mac") { - sources = - [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ] + sources = [ "${root_out_dir}/obj/third_party/typescript/typescript-4.2.3-r2.tgz" ] outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] module_source_dir = target_out_dir + "/$target_name" @@ -111,11 +123,11 @@ ohos_copy("ts2abc_deps_mac") { license_file = "//third_party/typescript/LICENSE" part_name = "ets_frontend" subsystem_name = "arkcompiler" + deps = [ "//third_party/typescript:build_typescript" ] } ohos_copy("ts2abc_deps_mac_ets") { - sources = - [ "//third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz" ] + sources = [ "${root_out_dir}/obj/third_party/typescript/typescript-4.2.3-r2.tgz" ] outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] module_source_dir = target_out_dir + "/$target_name" @@ -123,6 +135,7 @@ ohos_copy("ts2abc_deps_mac_ets") { license_file = "//third_party/typescript/LICENSE" part_name = "ets_frontend" subsystem_name = "arkcompiler" + deps = [ "//third_party/typescript:build_typescript" ] } action("ts2abc_diagnostic_ts") { @@ -160,6 +173,7 @@ action("npm_run_build") { deps = [ "$ts2abc_root:config_files", "$ts2abc_root:node_modules", + "$ts2abc_root:npm_install_tsc", "$ts2abc_root:ts2abc_diagnostic_ts", "$ts2abc_root:ts2abc_irnodes_ts", "$ts2abc_root:ts2abc_src", diff --git a/ts2panda/deps/ohos-typescript-4.2.3-r2.tgz b/ts2panda/deps/ohos-typescript-4.2.3-r2.tgz deleted file mode 120000 index 03a9d71c8613d6d1882c4389a355f258fc477fe5..0000000000000000000000000000000000000000 --- a/ts2panda/deps/ohos-typescript-4.2.3-r2.tgz +++ /dev/null @@ -1 +0,0 @@ -../../../../third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz \ No newline at end of file diff --git a/ts2panda/npm_install_tsc.py b/ts2panda/npm_install_tsc.py new file mode 100755 index 0000000000000000000000000000000000000000..b2f83f95602fef7da09d7354ed263cf4efc58c75 --- /dev/null +++ b/ts2panda/npm_install_tsc.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +import sys +import subprocess +import os + +def run_cmd(cmd, execution_path = None): + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stdin=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=execution_path, + shell=True) + stdout, stderr = proc.communicate() + if proc.returncode != 0: + print(stdout.decode(), stderr.decode()) + raise Exception(stderr.decode()) + +def run(args): + tsc_path = args[0] + cur_path = args[2] + deps_path = os.path.join(cur_path, "deps") + if not os.path.exists(deps_path): + os.makedirs(deps_path, exist_ok= True) + + tsc_package_path = os.path.join(deps_path, "typescript-4.2.3-r2.tgz") + cmd = " ".join(["cp", "-f", tsc_path, deps_path]) + run_cmd(cmd) + cmd = " ".join(["npm", "install", tsc_path, "--legacy-peer-deps"]) + run_cmd(cmd, args[1]) + cmd = " ".join(["npm", "install", tsc_package_path, "--legacy-peer-deps"]) + run_cmd(cmd, cur_path) + + if os.path.exists(args[3]): + cmd =" ".join(["rm", "-rf", args[3]]) + run_cmd(cmd) + +if __name__ == "__main__": + run(sys.argv[1:]) \ No newline at end of file diff --git a/ts2panda/package-lock.json b/ts2panda/package-lock.json index 17e3f56ffde260d8cdd837198ff533ede59ee57d..c65c43458fce4a21227359c6a6da05365ab0b9b9 100644 --- a/ts2panda/package-lock.json +++ b/ts2panda/package-lock.json @@ -4468,11 +4468,6 @@ "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, - "typescript": { - "version": "file:deps/ohos-typescript-4.2.3-r2.tgz", - "integrity": "sha512-Kw2DlAAicDbrE0iPhktxkw9AaujBy2N0qILDVuR/DKaJcd2Jo26kBQdheHKRFkyF8h+OYwZgjOpzUjn3eNLMyg==", - "dev": true - }, "typical": { "version": "4.0.0", "resolved": "https://repo.huaweicloud.com/repository/npm/typical/-/typical-4.0.0.tgz", diff --git a/ts2panda/package.json b/ts2panda/package.json index 9b94500b79e8dd788f8764dfd5dd289d81d1b9a8..e8e69543fd88a3bd5c2aac1bedd82abf6676707f 100644 --- a/ts2panda/package.json +++ b/ts2panda/package.json @@ -29,7 +29,6 @@ "ts-loader": "^5.3.3", "tslint": "^5.11.0", "ts-sinon": "^1.2.1", - "typescript": "file:./deps/ohos-typescript-4.2.3-r2.tgz", "webpack": "^5.70.0", "webpack-cli": "^4.9.2" },