Build typescript and arkguard in product building

Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/I8M0XX

Signed-off-by: zhangchen <zhangchen168@huawei.com>
Change-Id: I23a319126b844f6a4e6e74786bef106af72fa40c
This commit is contained in:
zhangchen 2023-12-05 10:15:07 +00:00
parent 06fcbda35a
commit e1bd3673de
4 changed files with 91 additions and 55 deletions

View File

@ -38,6 +38,7 @@ action("build_ets_loader_library") {
deps = [
":components",
":form_components",
":install_arkguard_tsc",
":server",
]
script = "build_ets_loader_library.py"
@ -136,7 +137,10 @@ ets_loader_sources = [
]
ohos_copy("ets_loader") {
deps = [ ":build_ets_loader_library" ]
deps = [
":build_ets_loader_library",
":install_arkguard_tsc",
]
sources = ets_loader_sources
deps += [ ":build_ets_sysResource" ]
sources += [ ets_sysResource ]
@ -209,7 +213,10 @@ ohos_copy("ets_loader_declaration") {
}
ohos_copy("ets_loader_ark") {
deps = [ ":build_ets_loader_library" ]
deps = [
":build_ets_loader_library",
":install_arkguard_tsc",
]
sources = ets_loader_sources
deps += [ ":build_ets_sysResource" ]
sources += [ ets_sysResource ]
@ -298,3 +305,20 @@ ohos_copy("ets_loader_ark_hap") {
outputs = [ target_out_dir + "/../../developtools/api/{{source_file_part}}" ]
module_install_name = ""
}
action("install_arkguard_tsc") {
deps = [
"//arkcompiler/ets_frontend/arkguard:build_arkguard",
"//third_party/typescript:build_typescript",
]
script = "install_arkguard_tsc.py"
args = [
rebase_path(
"${root_out_dir}/obj/third_party/typescript/ohos-typescript-4.9.5-r4.tgz"),
rebase_path(
"${root_out_dir}/obj/arkcompiler/ets_frontend/arkguard/arkguard-1.1.3.tgz"),
rebase_path("//developtools/ace_ets2bundle/compiler"),
current_os,
]
outputs = [ "${target_out_dir}/${target_name}.stamp" ]
}

View File

@ -1910,48 +1910,6 @@
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
},
"arkguard": {
"version": "1.1.3",
"resolved": "https://repo.huaweicloud.com/repository/npm/arkguard/-/arkguard-1.1.3.tgz",
"integrity": "sha512-iRedoO1wtiZNy2nJA6Q7+eqLfOjSV7LXfuRNpo6MNDuKilNyJuOLSu/CN7GObCKj5GEGD8uJdys5ix2FsqjTPQ==",
"requires": {
"commander": "^9.3.0",
"fs-extra": "^10.1.0",
"json5": "^2.2.3",
"source-map": "0.7.4"
},
"dependencies": {
"commander": {
"version": "9.5.0",
"resolved": "https://repo.huaweicloud.com/repository/npm/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ=="
},
"fs-extra": {
"version": "10.1.0",
"resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.1.0.tgz",
"integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
}
},
"jsonfile": {
"version": "6.1.0",
"resolved": "https://repo.huaweicloud.com/repository/npm/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"requires": {
"graceful-fs": "^4.1.6",
"universalify": "^2.0.0"
}
},
"universalify": {
"version": "2.0.1",
"resolved": "https://repo.huaweicloud.com/repository/npm/universalify/-/universalify-2.0.1.tgz",
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw=="
}
}
},
"array-union": {
"version": "1.0.2",
"resolved": "https://repo.huaweicloud.com/repository/npm/array-union/-/array-union-1.0.2.tgz",
@ -3238,7 +3196,8 @@
"json5": {
"version": "2.2.3",
"resolved": "https://repo.huaweicloud.com/repository/npm/json5/-/json5-2.2.3.tgz",
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"dev": true
},
"jsonfile": {
"version": "4.0.0",
@ -4146,14 +4105,6 @@
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
"dev": true
},
"typescript": {
"version": "npm:ohos-typescript@4.9.5-r6",
"resolved": "https://repo.huaweicloud.com/repository/npm/ohos-typescript/-/ohos-typescript-4.9.5-r6.tgz",
"integrity": "sha512-gwQq8e28xPdGNrIUXYM175N53fevIJOOuSOB45+X8neyhXT6nk8A+W6H46ejXIgMnHCR31OYidKrqAtGY26AhQ==",
"requires": {
"json5": "2.2.3"
}
},
"uglify-js": {
"version": "3.17.4",
"resolved": "https://repo.huaweicloud.com/repository/npm/uglify-js/-/uglify-js-3.17.4.tgz",

View File

@ -48,8 +48,6 @@
"log4js": "6.7.1",
"source-map": "0.7.4",
"ts-loader": "9.4.2",
"typescript": "npm:ohos-typescript@4.9.5-r6",
"arkguard": "1.1.3",
"webpack": "5.72.1",
"webpack-cli": "5.0.2",
"ws": "8.5.0"

63
install_arkguard_tsc.py Executable file
View File

@ -0,0 +1,63 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import os
import sys
import subprocess
import shutil
import tarfile
def extract(package_path, dest_path, package_name, current_os):
dest_package_path = os.path.join(dest_path, package_name)
temp_package_path = os.path.join(dest_path, current_os + package_name)
if (os.path.exists(dest_package_path) or os.path.exists(temp_package_path)):
return
os.makedirs(temp_package_path, exist_ok=True)
try:
with tarfile.open(package_path, 'r:gz') as tar:
tar.extractall(path=temp_package_path)
except tarfile.TarError as e:
print(f'Error extracting files: {e}')
package_path = os.path.join(temp_package_path, 'package')
if not (os.path.exists(dest_package_path)):
# The default name of the decompressed npm package is package. it needs to be renamed to the specified name.
shutil.copytree(package_path, dest_package_path, symlinks=True, dirs_exist_ok=True)
run_cmd(['rm', '-rf', temp_package_path])
def run_cmd(cmd, execution_ath=None):
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=execution_ath)
stdout, stderr = proc.communicate(timeout=60)
if proc.returncode != 0:
raise Exception(stderr.decode())
def run(args):
tsc_path = args[0]
arkguard_path = args[1]
source_path = args[2]
current_os = args[3]
node_modules_path = os.path.join(source_path, "node_modules")
extract(tsc_path, node_modules_path, 'typescript', current_os)
extract(arkguard_path, node_modules_path, 'arkguard', current_os)
if __name__ == "__main__":
run(sys.argv[1:])