1#!/usr/bin/env python3 2# encoding=utf-8 3# ============================================================================ 4# @brief build system entry, receive param & start to build 5 6# Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 7# Licensed under the Apache License, Version 2.0 (the "License"); 8# you may not use this file except in compliance with the License. 9# You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, software 14# distributed under the License is distributed on an "AS IS" BASIS, 15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16# See the License for the specific language governing permissions and 17# limitations under the License. 18# ============================================================================ 19""" 20接收参数列表及解释: 21 -c: 22 clean后编译 23 -j: 24 -j<num>, 以num线程数编译 25 默认为机器最大线程数 26 -def=: 27 -def=XXX,YYY,ZZZ=x,... 向本次编译target中添加XXX、YYY、ZZZ=x编译宏 28 可使用-def=-:XXX 来屏蔽XXX宏 29 可使用-def=-:ZZZ=x 来添加或者修改ZZZ宏 30 -component=: 31 -component=XXX,YYY,... 仅编译XXX,YYY组件 32 -ninja: 33 使用ninja生成中间文件 34 默认使用Unix makefile 35 -[release/debug]: 36 debug: 在生成反汇编文件时信息更加全面但也更耗时 37 release: 在生成反汇编文件时节省时间 38 默认为debug 39 -dump: 40 输出target的编译参数 41 -nhso: 42 不更新HSO数据库 43 -out_libs: 44 -out_libs=file_path, 不再链接成elf, 转而将所有.a打包成一个大的.a 45 others: 46 作为匹配编译target_names的关键字 47""" 48import os 49import sys 50from distutils.spawn import find_executable 51 52sys.dont_write_bytecode = True 53root_dir = os.path.split(os.path.realpath(__file__))[0] 54sys.path.append(os.path.join(root_dir, 'build', 'config')) 55sys.path.append(os.path.join(root_dir, 'build', 'script')) 56 57from cmake_builder import CMakeBuilder 58 59def check_enviroment(): 60 if not find_executable("cmake"): 61 print("cmake is not installed or not added to system path.") 62 if not find_executable("ninja") and not find_executable("make"): 63 print("make/ninja is not installed or not added to system path.") 64 65builder = CMakeBuilder(sys.argv) 66 67builder.build() 68