diff --git a/bsp/at32/tools/sdk_dist.py b/bsp/at32/tools/sdk_dist.py index 3aafefe582..52960801fa 100644 --- a/bsp/at32/tools/sdk_dist.py +++ b/bsp/at32/tools/sdk_dist.py @@ -1,9 +1,11 @@ import os import sys import shutil + cwd_path = os.getcwd() sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + def bsp_update_kconfig_library(dist_dir): # change RTT_ROOT in Kconfig if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): @@ -12,16 +14,12 @@ def bsp_update_kconfig_library(dist_dir): with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: data = f.readlines() with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: - found = 0 for line in data: - if line.find('RTT_ROOT') != -1: - found = 1 - if line.find('../libraries') != -1 and found: - position = line.find('../libraries') - line = line[0:position] + 'libraries/Kconfig"\n' - found = 0 + if line.find('source') != -1 and line.find('../libraries') != -1: + line = line.replace('../libraries', 'libraries') f.write(line) + # BSP dist function def dist_do_building(BSP_ROOT, dist_dir): from mkdist import bsp_copy_files @@ -30,12 +28,14 @@ def dist_do_building(BSP_ROOT, dist_dir): print("=> copy at32 bsp library") library_dir = os.path.join(dist_dir, 'libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') - bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), - os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) + bsp_copy_files( + os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), + os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE), + ) print("=> copy bsp drivers") bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers')) bsp_copy_files(os.path.join(library_path, 'usbd_library'), os.path.join(library_dir, 'usbd_library')) bsp_copy_files(os.path.join(library_path, 'usbotg_library'), os.path.join(library_dir, 'usbotg_library')) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) - bsp_update_kconfig_library(dist_dir) \ No newline at end of file + bsp_update_kconfig_library(dist_dir) diff --git a/bsp/bouffalo_lab/bl808/tools/sdk_dist.py b/bsp/bouffalo_lab/bl808/tools/sdk_dist.py index 5a467a3a6d..db2d35ccfa 100644 --- a/bsp/bouffalo_lab/bl808/tools/sdk_dist.py +++ b/bsp/bouffalo_lab/bl808/tools/sdk_dist.py @@ -1,18 +1,20 @@ import os import sys import shutil + cwd_path = os.getcwd() sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + # BSP dist function def dist_do_building(BSP_ROOT, dist_dir): from mkdist import bsp_copy_files import rtconfig library_path = os.path.join(os.path.dirname(BSP_ROOT), '../libraries') - print("library_path ",library_path) - library_dir = os.path.join(dist_dir, 'libraries') - print("library_dir ",library_dir) + print("library_path ", library_path) + library_dir = os.path.join(dist_dir, 'libraries') + print("library_dir ", library_dir) print("=> copy bsp drivers") bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers')) print("=> copy bsp CMSIS") @@ -20,7 +22,7 @@ def dist_do_building(BSP_ROOT, dist_dir): print("=> copy bsp library") shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) - + # change RTT_ROOT in Kconfig if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): return @@ -28,12 +30,7 @@ def dist_do_building(BSP_ROOT, dist_dir): with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: data = f.readlines() with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: - found = 0 for line in data: - if line.find('RTT_ROOT') != -1: - found = 1 - if line.find('../../libraries') != -1 and found: - position = line.find('../../libraries') - line = line[0:position] + 'libraries"\n' - found = 0 + if line.find('source') != -1 and line.find('../libraries') != -1: + line = line.replace('../libraries', 'libraries') f.write(line) diff --git a/bsp/core-v-mcu/tools/sdk_dist.py b/bsp/core-v-mcu/tools/sdk_dist.py index b0728bd3af..56d6b6b1fa 100644 --- a/bsp/core-v-mcu/tools/sdk_dist.py +++ b/bsp/core-v-mcu/tools/sdk_dist.py @@ -1,10 +1,12 @@ import os import sys import shutil + cwd_path = os.getcwd() -#cwd_path = E:\rt-thread\bsp\core-v-mcu\tools +# cwd_path = E:\rt-thread\bsp\core-v-mcu\tools sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + # BSP dist function def dist_do_building(BSP_ROOT, dist_dir): from mkdist import bsp_copy_files @@ -13,25 +15,19 @@ def dist_do_building(BSP_ROOT, dist_dir): print("=> copy core-v bsp library") library_dir = os.path.join(dist_dir, 'Libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') - bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), - os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) - #library_dir = E:\rt-thread\bsp\core-v-mcu\Libraries + bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) + # library_dir = E:\rt-thread\bsp\core-v-mcu\Libraries print("=> copy bsp drivers") bsp_copy_files(os.path.join(library_path, 'core_v_drivers'), os.path.join(library_dir, 'core_v_drivers')) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) -# change RTT_ROOT in Kconfig + # change RTT_ROOT in Kconfig if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): return with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: data = f.readlines() with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: - found = 0 for line in data: - if line.find('RTT_ROOT') != -1: - found = 1 - if line.find('../Libraries') != -1 and found: - position = line.find('../Libraries') - line = line[0:position] + 'Libraries/Kconfig"\n' - found = 0 + if line.find('source') != -1 and line.find('../libraries') != -1: + line = line.replace('../libraries', 'libraries') f.write(line) diff --git a/bsp/ht32/tools/sdk_dist.py b/bsp/ht32/tools/sdk_dist.py index b239eb7d13..01540d7ec6 100644 --- a/bsp/ht32/tools/sdk_dist.py +++ b/bsp/ht32/tools/sdk_dist.py @@ -2,9 +2,11 @@ import os import re import sys import shutil + cwd_path = os.getcwd() sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + def bsp_update_kconfig_library(dist_dir): # change RTT_ROOT in Kconfig if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): @@ -13,16 +15,12 @@ def bsp_update_kconfig_library(dist_dir): with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: data = f.readlines() with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: - found = 0 for line in data: - if line.find('RTT_ROOT') != -1: - found = 1 - if line.find('../libraries') != -1 and found: - position = line.find('../libraries') - line = line[0:position] + 'libraries/Kconfig"\n' - found = 0 + if line.find('source') != -1 and line.find('../libraries') != -1: + line = line.replace('../libraries', 'libraries') f.write(line) + # BSP dist function def dist_do_building(BSP_ROOT, dist_dir): from mkdist import bsp_copy_files @@ -31,14 +29,14 @@ def dist_do_building(BSP_ROOT, dist_dir): print("=> copy ht32 bsp library") library_dir = os.path.join(dist_dir, 'libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') - bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), - os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) + bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) print("=> copy bsp drivers") bsp_copy_files(os.path.join(library_path, 'ht32_drivers'), os.path.join(library_dir, 'ht32_drivers')) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) bsp_update_kconfig_library(dist_dir) - + + def get_source(ic_model, file_path, system_path, base_path): source_path = [] files_list = [] @@ -47,7 +45,7 @@ def get_source(ic_model, file_path, system_path, base_path): return with open(file_path, 'r') as file: - #content = file.read() + # content = file.read() for line in file: if readafter == 2 and line.find('>') != -1: break @@ -56,10 +54,10 @@ def get_source(ic_model, file_path, system_path, base_path): if line.find(ic_model) != -1: readafter = 1 if readafter == 1 and line.find('<') != -1: - readafter = 2 + readafter = 2 for line in files_list: if line.find('system') != -1: source_path.append(os.path.join(system_path, line.strip())) else: source_path.append(os.path.join(base_path, line.strip())) - return source_path + return source_path diff --git a/bsp/nxp/lpc/lpc55sxx/tools/sdk_dist.py b/bsp/nxp/lpc/lpc55sxx/tools/sdk_dist.py index 4a474023c2..ccf0cc75a1 100644 --- a/bsp/nxp/lpc/lpc55sxx/tools/sdk_dist.py +++ b/bsp/nxp/lpc/lpc55sxx/tools/sdk_dist.py @@ -1,16 +1,18 @@ import os import sys import shutil + cwd_path = os.getcwd() sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + # BSP dist function def dist_do_building(BSP_ROOT, dist_dir): from mkdist import bsp_copy_files import rtconfig library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') - library_dir = os.path.join(dist_dir, 'Libraries') + library_dir = os.path.join(dist_dir, 'Libraries') print("=> copy bsp drivers") bsp_copy_files(os.path.join(library_path, 'drivers'), os.path.join(library_dir, 'drivers')) print("=> copy bsp CMSIS") @@ -18,7 +20,7 @@ def dist_do_building(BSP_ROOT, dist_dir): print("=> copy bsp library") bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) - + # change RTT_ROOT in Kconfig if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): return @@ -26,12 +28,7 @@ def dist_do_building(BSP_ROOT, dist_dir): with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: data = f.readlines() with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: - found = 0 for line in data: - if line.find('RTT_ROOT') != -1: - found = 1 - if line.find('../Libraries') != -1 and found: - position = line.find('../Libraries') - line = line[0:position] + 'Libraries/Kconfig"\n' - found = 0 + if line.find('source') != -1 and line.find('../libraries') != -1: + line = line.replace('../Libraries', 'Libraries') f.write(line) diff --git a/bsp/wch/arm/tools/sdk_dist.py b/bsp/wch/arm/tools/sdk_dist.py index 7fa1e817a6..37a1abfed6 100644 --- a/bsp/wch/arm/tools/sdk_dist.py +++ b/bsp/wch/arm/tools/sdk_dist.py @@ -1,9 +1,11 @@ import os import sys import shutil + cwd_path = os.getcwd() sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + # BSP dist function def dist_do_building(BSP_ROOT, dist_dir): from mkdist import bsp_copy_files @@ -12,25 +14,22 @@ def dist_do_building(BSP_ROOT, dist_dir): print("=> copy ch32 bsp library") library_dir = os.path.join(dist_dir, 'Libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') - bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), - os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) + bsp_copy_files( + os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), + os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE), + ) print("=> copy bsp drivers") bsp_copy_files(os.path.join(library_path, 'ch32_drivers'), os.path.join(library_dir, 'ch32_drivers')) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) -# change RTT_ROOT in Kconfig + # change RTT_ROOT in Kconfig if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): return with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: data = f.readlines() with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: - found = 0 for line in data: - if line.find('RTT_ROOT') != -1: - found = 1 - if line.find('../Libraries') != -1 and found: - position = line.find('../Libraries') - line = line[0:position] + 'Libraries/Kconfig"\n' - found = 0 + if line.find('source') != -1 and line.find('../libraries') != -1: + line = line.replace('../Libraries', 'Libraries') f.write(line) diff --git a/bsp/wch/risc-v/tools/sdk_dist.py b/bsp/wch/risc-v/tools/sdk_dist.py index 7fa1e817a6..d426d97805 100644 --- a/bsp/wch/risc-v/tools/sdk_dist.py +++ b/bsp/wch/risc-v/tools/sdk_dist.py @@ -1,9 +1,11 @@ import os import sys import shutil + cwd_path = os.getcwd() sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + # BSP dist function def dist_do_building(BSP_ROOT, dist_dir): from mkdist import bsp_copy_files @@ -12,25 +14,19 @@ def dist_do_building(BSP_ROOT, dist_dir): print("=> copy ch32 bsp library") library_dir = os.path.join(dist_dir, 'Libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') - bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), - os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) + bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) print("=> copy bsp drivers") bsp_copy_files(os.path.join(library_path, 'ch32_drivers'), os.path.join(library_dir, 'ch32_drivers')) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) -# change RTT_ROOT in Kconfig + # change RTT_ROOT in Kconfig if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): return with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: data = f.readlines() with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: - found = 0 for line in data: - if line.find('RTT_ROOT') != -1: - found = 1 - if line.find('../Libraries') != -1 and found: - position = line.find('../Libraries') - line = line[0:position] + 'Libraries/Kconfig"\n' - found = 0 + if line.find('source') != -1 and line.find('../libraries') != -1: + line = line.replace('../Libraries', 'Libraries') f.write(line) diff --git a/tools/mkdist.py b/tools/mkdist.py index 246c8e7a7d..ea1a0c96fc 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -126,14 +126,9 @@ def bsp_update_kconfig(dist_dir): with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: data = f.readlines() with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: - found = 0 for line in data: - if line.find('RTT_ROOT') != -1: - found = 1 - if line.find('default') != -1 and found: - position = line.find('default') - line = line[0:position] + 'default "rt-thread"\n' - found = 0 + if line.find('RTT_DIR') != -1 and line.find(':=') != -1: + line = 'RTT_DIR := rt-thread\n' f.write(line) def bsp_update_kconfig_library(dist_dir): @@ -144,14 +139,9 @@ def bsp_update_kconfig_library(dist_dir): with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: data = f.readlines() with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: - found = 0 for line in data: - if line.find('RTT_ROOT') != -1: - found = 1 - if line.find('../libraries') != -1 and found: - position = line.find('../libraries') - line = line[0:position] + 'libraries/Kconfig"\n' - found = 0 + if line.find('source') != -1 and line.find('../libraries') != -1: + line = line.replace('../libraries', 'libraries') f.write(line) # change board/kconfig path @@ -162,9 +152,8 @@ def bsp_update_kconfig_library(dist_dir): data = f.readlines() with open(os.path.join(dist_dir, 'board/Kconfig'), 'w') as f: for line in data: - if line.find('../libraries/HAL_Drivers/drivers/Kconfig') != -1: - position = line.find('../libraries/HAL_Drivers/drivers/Kconfig') - line = line[0:position] + 'libraries/HAL_Drivers/drivers/Kconfig"\n' + if line.find('source') != -1 and line.find('../libraries') != -1: + line = line.replace('../libraries', 'libraries') f.write(line) def zip_dist(dist_dir, dist_name):