1# Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14 15import argparse 16import os 17import shutil 18 19 20if __name__ == '__main__': 21 parser = argparse.ArgumentParser(description="copy_files_to_interim") 22 parser.add_argument('proj_root_dir', help="proj root dir") 23 24 args = parser.parse_args() 25 26 proj_root_dir = args.proj_root_dir 27 28 target_dir = os.path.join(proj_root_dir, "interim_binary", "ws63", "bin", "boot_bin") 29 if not os.path.isdir(target_dir): 30 os.makedirs(target_dir) 31 32 hilink_target_dir = os.path.join(proj_root_dir, "interim_binary", "ws63", "bin", "hilink_bin") 33 if not os.path.isdir(hilink_target_dir): 34 os.makedirs(hilink_target_dir) 35 36 # key is src file, value is dest file or dir 37 copy_map = { 38 'output/ws63/acore/ws63-loaderboot/loaderboot.bin' : target_dir, 39 'output/ws63/acore/ws63-loaderboot/root_loaderboot_sign.bin' : target_dir, 40 'output/ws63/acore/ws63-liteos-app/efuse_cfg.bin' : target_dir, 41 'output/ws63/acore/ws63-ssb/ssb.bin' : target_dir, 42 'output/ws63/acore/ws63-ssb/ssb_sign.bin' : target_dir, 43 'output/ws63/acore/ws63-flashboot/flashboot.bin' : target_dir, 44 'output/ws63/acore/ws63-flashboot/flashboot_sign.bin' : target_dir, 45 'output/ws63/acore/ws63-flashboot/flashboot_backup_sign.bin' : target_dir, 46 'output/ws63/acore/ws63-liteos-hilink/ws63-liteos-hilink.bin' : hilink_target_dir, 47 'output/ws63/acore/ws63-liteos-hilink/ws63-liteos-hilink-sign.bin' : hilink_target_dir, 48 } 49 50 for src_file, dest in copy_map.items(): 51 src_file = os.path.join(proj_root_dir, src_file) 52 if not os.path.isfile(src_file): 53 print(f'[!][copy_files_to_interim] File `{src_file}` not found, will skip it !') 54 continue 55 filename = src_file.split('/')[-1] 56 if not os.path.isfile(os.path.join(target_dir, filename)): 57 continue 58 try: 59 shutil.copy(src_file, dest) 60 except BaseException as e: 61 print(e) 62 exit(-1) 63