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 20import struct 21import sys 22 23def concat_bins(file1, file2, file1_size, output): 24 # 读取两个bin文件 25 with open(file1, 'rb') as f1, open(file2, 'rb') as f2: 26 data_file1 = f1.read() 27 data_file2 = f2.read() 28 29 with open(output, 'wb') as out: 30 out.seek(0, 0) 31 out.write(data_file1) 32 out.seek(int(file1_size, 16), 0) 33 out.write(data_file2) 34 35def main(): 36 # 获取命令行传入的参数列表 37 args = sys.argv[1:] 38 # 判断参数是否为文件路径 39 if len(args) == 4: 40 concat_bins(args[0], args[1], args[2], args[3]) 41 else: 42 sys.exit(0) 43 44if __name__ == '__main__': 45 main() 46