1#!/usr/bin/env python3 2# coding=utf-8 3# Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 16""" 17* Description: Utilities of compile system. 18* Change: 2023-3-17 19""" 20import os 21import sys 22import glob 23 24def generate_nv_source(input, output): 25 if input == 'noneed': 26 headers = glob.glob(os.path.join("*.h")) 27 else: 28 headers = glob.glob(os.path.join(input, "*.h")) 29 # dummy C file that includes all the required headers to get structure defs. 30 lines = [] 31 for header in headers: 32 lines.append('#include <%s>' % os.path.basename(header)) 33 34 with open(output, "w") as f: 35 f.write("\n".join(lines)) # for compatible representation to old implementation. 36 37def generate_nv_dir(nv_c_path): 38 if not os.path.exists(nv_c_path): 39 os.makedirs(nv_c_path) 40 41if __name__ == "__main__": 42 if sys.argv[1] == 'NV': 43 generate_nv_source(sys.argv[2], sys.argv[3]) 44 if sys.argv[1] == 'MKPATH': 45 generate_nv_dir(sys.argv[2])