1 Star 0 Fork 224

kangchongtao/js_api_module

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build_ts_js.py 2.13 KB
一键复制 编辑 原始数据 按行查看 历史
shikai-123 提交于 2022-03-07 15:38 . Modify review message
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2022 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 os
import shutil
import platform
import argparse
import subprocess
def run_command(in_cmd):
print(" ".join(in_cmd))
proc = subprocess.Popen(in_cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
shell=False)
stdout, stderr = proc.communicate()
if stdout != "":
raise Exception(stdout)
if __name__ == '__main__':
PARSER_INST = argparse.ArgumentParser()
PARSER_INST.add_argument('--dst-file',
help='the converted target file')
PARSER_INST.add_argument('--module-path',
help='the module path')
PARSER_INST.add_argument('--out-file',
help='js output file')
INPUT_ARGUMENTS = PARSER_INST.parse_args()
BUILD_PATH = os.path.abspath(os.path.join(os.getcwd(), "../.."))
os.chdir(("%s" + INPUT_ARGUMENTS.module_path) % BUILD_PATH)
NODE_PATH = '../../../../prebuilts/build-tools/common/nodejs/\
node-v12.18.4-linux-x64/bin/node'
if not os.path.exists(NODE_PATH):
raise Exception('NO souch file or directory')
TSC_PATH = '../../../../ark/ts2abc/ts2panda/node_modules/\
typescript/bin/tsc'
CMD_INST = [NODE_PATH, TSC_PATH]
run_command(CMD_INST)
if not os.path.exists(INPUT_ARGUMENTS.out_file):
raise Exception('error:NO souch file or directory')
CMD_INST = shutil.copy(INPUT_ARGUMENTS.out_file, INPUT_ARGUMENTS.dst_file)
CMD_INST = shutil.rmtree('./out')
exit(0)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kangchongtao/js_api_module.git
git@gitee.com:kangchongtao/js_api_module.git
kangchongtao
js_api_module
js_api_module
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385