2020-04-22 16:58:10 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import shutil
|
|
|
|
cwd_path = os.getcwd()
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
|
|
|
|
|
2021-08-24 13:40:58 +08:00
|
|
|
def bsp_update_kconfig_library(dist_dir):
|
|
|
|
# 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
|
2022-03-25 22:54:51 +08:00
|
|
|
if line.find('../libraries') != -1 and found:
|
|
|
|
position = line.find('../libraries')
|
|
|
|
line = line[0:position] + 'libraries/Kconfig"\n'
|
2021-08-24 13:40:58 +08:00
|
|
|
found = 0
|
|
|
|
f.write(line)
|
|
|
|
|
2020-04-22 16:58:10 +08:00
|
|
|
# BSP dist function
|
2020-06-14 12:21:20 +08:00
|
|
|
def dist_do_building(BSP_ROOT, dist_dir):
|
2020-04-22 16:58:10 +08:00
|
|
|
from mkdist import bsp_copy_files
|
|
|
|
import rtconfig
|
2020-06-14 12:21:20 +08:00
|
|
|
|
|
|
|
print("=> copy at32 bsp library")
|
2022-03-25 22:54:51 +08:00
|
|
|
library_dir = os.path.join(dist_dir, 'libraries')
|
|
|
|
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries')
|
2020-06-14 12:21:20 +08:00
|
|
|
bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE),
|
|
|
|
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
|
|
|
|
|
2020-04-22 16:58:10 +08:00
|
|
|
print("=> copy bsp drivers")
|
|
|
|
bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers'))
|
2023-02-25 10:47:04 +08:00
|
|
|
bsp_copy_files(os.path.join(library_path, 'usbd_library'), os.path.join(library_dir, 'usbd_library'))
|
2023-11-09 16:38:19 +08:00
|
|
|
bsp_copy_files(os.path.join(library_path, 'usbotg_library'), os.path.join(library_dir, 'usbotg_library'))
|
2020-04-22 16:58:10 +08:00
|
|
|
shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
|
2021-08-24 13:40:58 +08:00
|
|
|
bsp_update_kconfig_library(dist_dir)
|