1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3# Copyright (c) 2021 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16import argparse 17import sys 18import os 19import shutil 20import subprocess 21 22INTERFACE_PATH = "interface/sdk-js" 23PARSE_ETS2_API = "interface/sdk-js/build-tools/handleApiFiles.js" 24 25 26def parse_ets2_api(options): 27 nodejs = os.path.abspath(options.node_js) 28 tool = os.path.abspath(os.path.join(options.source_root_dir, 29 PARSE_ETS2_API)) 30 31 cwd_dir = os.path.abspath(os.path.join( 32 options.source_root_dir, INTERFACE_PATH)) 33 input_dir = os.path.abspath(options.input) 34 out_dir = os.path.abspath(options.output) 35 process = subprocess.run([nodejs, tool, "--path", input_dir, 36 "--output", out_dir, "--type", 37 options.type], shell=False, 38 cwd=os.path.abspath(os.path.join( 39 options.source_root_dir, cwd_dir)), 40 stdout=subprocess.PIPE) 41 return process 42 43 44def parse_step(options): 45 parse_ets2_api(options) 46 47 48def main(): 49 parser = argparse.ArgumentParser() 50 parser.add_argument('--input', required=True) 51 parser.add_argument('--output', required=True) 52 parser.add_argument('--type', required=True) 53 parser.add_argument('--source-root-dir', required=True) 54 parser.add_argument('--node-js', required=True) 55 options = parser.parse_args() 56 parse_step(options) 57 58 59if __name__ == '__main__': 60 sys.exit(main()) 61