mkdist和sdk_dist支持kconfiglib语法

This commit is contained in:
latercomer 2024-06-11 13:20:34 +08:00 committed by Rbb666
parent fe3c4d456e
commit f0e6d772f3
8 changed files with 64 additions and 92 deletions

View File

@ -1,9 +1,11 @@
import os import os
import sys import sys
import shutil import shutil
cwd_path = os.getcwd() cwd_path = os.getcwd()
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
def bsp_update_kconfig_library(dist_dir): def bsp_update_kconfig_library(dist_dir):
# change RTT_ROOT in Kconfig # change RTT_ROOT in Kconfig
if not os.path.isfile(os.path.join(dist_dir, '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: with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data: for line in data:
if line.find('RTT_ROOT') != -1: if line.find('source') != -1 and line.find('../libraries') != -1:
found = 1 line = line.replace('../libraries', 'libraries')
if line.find('../libraries') != -1 and found:
position = line.find('../libraries')
line = line[0:position] + 'libraries/Kconfig"\n'
found = 0
f.write(line) f.write(line)
# BSP dist function # BSP dist function
def dist_do_building(BSP_ROOT, dist_dir): def dist_do_building(BSP_ROOT, dist_dir):
from mkdist import bsp_copy_files from mkdist import bsp_copy_files
@ -30,8 +28,10 @@ def dist_do_building(BSP_ROOT, dist_dir):
print("=> copy at32 bsp library") print("=> copy at32 bsp library")
library_dir = os.path.join(dist_dir, 'libraries') library_dir = os.path.join(dist_dir, 'libraries')
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries')
bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), bsp_copy_files(
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE),
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE),
)
print("=> copy bsp drivers") 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, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers'))

View File

@ -1,9 +1,11 @@
import os import os
import sys import sys
import shutil import shutil
cwd_path = os.getcwd() cwd_path = os.getcwd()
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
# BSP dist function # BSP dist function
def dist_do_building(BSP_ROOT, dist_dir): def dist_do_building(BSP_ROOT, dist_dir):
from mkdist import bsp_copy_files from mkdist import bsp_copy_files
@ -28,12 +30,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data: for line in data:
if line.find('RTT_ROOT') != -1: if line.find('source') != -1 and line.find('../libraries') != -1:
found = 1 line = line.replace('../libraries', 'libraries')
if line.find('../../libraries') != -1 and found:
position = line.find('../../libraries')
line = line[0:position] + 'libraries"\n'
found = 0
f.write(line) f.write(line)

View File

@ -1,10 +1,12 @@
import os import os
import sys import sys
import shutil import shutil
cwd_path = os.getcwd() 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')) sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
# BSP dist function # BSP dist function
def dist_do_building(BSP_ROOT, dist_dir): def dist_do_building(BSP_ROOT, dist_dir):
from mkdist import bsp_copy_files from mkdist import bsp_copy_files
@ -13,8 +15,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
print("=> copy core-v bsp library") print("=> copy core-v bsp library")
library_dir = os.path.join(dist_dir, 'Libraries') library_dir = os.path.join(dist_dir, 'Libraries')
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries')
bsp_copy_files(os.path.join(library_path, 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))
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
# library_dir = E:\rt-thread\bsp\core-v-mcu\Libraries # library_dir = E:\rt-thread\bsp\core-v-mcu\Libraries
print("=> copy bsp drivers") print("=> copy bsp drivers")
bsp_copy_files(os.path.join(library_path, 'core_v_drivers'), os.path.join(library_dir, 'core_v_drivers')) bsp_copy_files(os.path.join(library_path, 'core_v_drivers'), os.path.join(library_dir, 'core_v_drivers'))
@ -26,12 +27,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data: for line in data:
if line.find('RTT_ROOT') != -1: if line.find('source') != -1 and line.find('../libraries') != -1:
found = 1 line = line.replace('../libraries', 'libraries')
if line.find('../Libraries') != -1 and found:
position = line.find('../Libraries')
line = line[0:position] + 'Libraries/Kconfig"\n'
found = 0
f.write(line) f.write(line)

View File

@ -2,9 +2,11 @@ import os
import re import re
import sys import sys
import shutil import shutil
cwd_path = os.getcwd() cwd_path = os.getcwd()
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
def bsp_update_kconfig_library(dist_dir): def bsp_update_kconfig_library(dist_dir):
# change RTT_ROOT in Kconfig # change RTT_ROOT in Kconfig
if not os.path.isfile(os.path.join(dist_dir, '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: with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data: for line in data:
if line.find('RTT_ROOT') != -1: if line.find('source') != -1 and line.find('../libraries') != -1:
found = 1 line = line.replace('../libraries', 'libraries')
if line.find('../libraries') != -1 and found:
position = line.find('../libraries')
line = line[0:position] + 'libraries/Kconfig"\n'
found = 0
f.write(line) f.write(line)
# BSP dist function # BSP dist function
def dist_do_building(BSP_ROOT, dist_dir): def dist_do_building(BSP_ROOT, dist_dir):
from mkdist import bsp_copy_files from mkdist import bsp_copy_files
@ -31,14 +29,14 @@ def dist_do_building(BSP_ROOT, dist_dir):
print("=> copy ht32 bsp library") print("=> copy ht32 bsp library")
library_dir = os.path.join(dist_dir, 'libraries') library_dir = os.path.join(dist_dir, 'libraries')
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries')
bsp_copy_files(os.path.join(library_path, 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))
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
print("=> copy bsp drivers") print("=> copy bsp drivers")
bsp_copy_files(os.path.join(library_path, 'ht32_drivers'), os.path.join(library_dir, 'ht32_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')) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
bsp_update_kconfig_library(dist_dir) bsp_update_kconfig_library(dist_dir)
def get_source(ic_model, file_path, system_path, base_path): def get_source(ic_model, file_path, system_path, base_path):
source_path = [] source_path = []
files_list = [] files_list = []

View File

@ -1,9 +1,11 @@
import os import os
import sys import sys
import shutil import shutil
cwd_path = os.getcwd() cwd_path = os.getcwd()
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
# BSP dist function # BSP dist function
def dist_do_building(BSP_ROOT, dist_dir): def dist_do_building(BSP_ROOT, dist_dir):
from mkdist import bsp_copy_files from mkdist import bsp_copy_files
@ -26,12 +28,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data: for line in data:
if line.find('RTT_ROOT') != -1: if line.find('source') != -1 and line.find('../libraries') != -1:
found = 1 line = line.replace('../Libraries', 'Libraries')
if line.find('../Libraries') != -1 and found:
position = line.find('../Libraries')
line = line[0:position] + 'Libraries/Kconfig"\n'
found = 0
f.write(line) f.write(line)

View File

@ -1,9 +1,11 @@
import os import os
import sys import sys
import shutil import shutil
cwd_path = os.getcwd() cwd_path = os.getcwd()
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
# BSP dist function # BSP dist function
def dist_do_building(BSP_ROOT, dist_dir): def dist_do_building(BSP_ROOT, dist_dir):
from mkdist import bsp_copy_files from mkdist import bsp_copy_files
@ -12,8 +14,10 @@ def dist_do_building(BSP_ROOT, dist_dir):
print("=> copy ch32 bsp library") print("=> copy ch32 bsp library")
library_dir = os.path.join(dist_dir, 'Libraries') library_dir = os.path.join(dist_dir, 'Libraries')
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries')
bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), bsp_copy_files(
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE),
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE),
)
print("=> copy bsp drivers") print("=> copy bsp drivers")
bsp_copy_files(os.path.join(library_path, 'ch32_drivers'), os.path.join(library_dir, 'ch32_drivers')) bsp_copy_files(os.path.join(library_path, 'ch32_drivers'), os.path.join(library_dir, 'ch32_drivers'))
@ -25,12 +29,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data: for line in data:
if line.find('RTT_ROOT') != -1: if line.find('source') != -1 and line.find('../libraries') != -1:
found = 1 line = line.replace('../Libraries', 'Libraries')
if line.find('../Libraries') != -1 and found:
position = line.find('../Libraries')
line = line[0:position] + 'Libraries/Kconfig"\n'
found = 0
f.write(line) f.write(line)

View File

@ -1,9 +1,11 @@
import os import os
import sys import sys
import shutil import shutil
cwd_path = os.getcwd() cwd_path = os.getcwd()
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
# BSP dist function # BSP dist function
def dist_do_building(BSP_ROOT, dist_dir): def dist_do_building(BSP_ROOT, dist_dir):
from mkdist import bsp_copy_files from mkdist import bsp_copy_files
@ -12,8 +14,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
print("=> copy ch32 bsp library") print("=> copy ch32 bsp library")
library_dir = os.path.join(dist_dir, 'Libraries') library_dir = os.path.join(dist_dir, 'Libraries')
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries')
bsp_copy_files(os.path.join(library_path, 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))
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
print("=> copy bsp drivers") print("=> copy bsp drivers")
bsp_copy_files(os.path.join(library_path, 'ch32_drivers'), os.path.join(library_dir, 'ch32_drivers')) bsp_copy_files(os.path.join(library_path, 'ch32_drivers'), os.path.join(library_dir, 'ch32_drivers'))
@ -25,12 +26,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data: for line in data:
if line.find('RTT_ROOT') != -1: if line.find('source') != -1 and line.find('../libraries') != -1:
found = 1 line = line.replace('../Libraries', 'Libraries')
if line.find('../Libraries') != -1 and found:
position = line.find('../Libraries')
line = line[0:position] + 'Libraries/Kconfig"\n'
found = 0
f.write(line) f.write(line)

View File

@ -126,14 +126,9 @@ def bsp_update_kconfig(dist_dir):
with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data: for line in data:
if line.find('RTT_ROOT') != -1: if line.find('RTT_DIR') != -1 and line.find(':=') != -1:
found = 1 line = 'RTT_DIR := rt-thread\n'
if line.find('default') != -1 and found:
position = line.find('default')
line = line[0:position] + 'default "rt-thread"\n'
found = 0
f.write(line) f.write(line)
def bsp_update_kconfig_library(dist_dir): 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: with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data: for line in data:
if line.find('RTT_ROOT') != -1: if line.find('source') != -1 and line.find('../libraries') != -1:
found = 1 line = line.replace('../libraries', 'libraries')
if line.find('../libraries') != -1 and found:
position = line.find('../libraries')
line = line[0:position] + 'libraries/Kconfig"\n'
found = 0
f.write(line) f.write(line)
# change board/kconfig path # change board/kconfig path
@ -162,9 +152,8 @@ def bsp_update_kconfig_library(dist_dir):
data = f.readlines() data = f.readlines()
with open(os.path.join(dist_dir, 'board/Kconfig'), 'w') as f: with open(os.path.join(dist_dir, 'board/Kconfig'), 'w') as f:
for line in data: for line in data:
if line.find('../libraries/HAL_Drivers/drivers/Kconfig') != -1: if line.find('source') != -1 and line.find('../libraries') != -1:
position = line.find('../libraries/HAL_Drivers/drivers/Kconfig') line = line.replace('../libraries', 'libraries')
line = line[0:position] + 'libraries/HAL_Drivers/drivers/Kconfig"\n'
f.write(line) f.write(line)
def zip_dist(dist_dir, dist_name): def zip_dist(dist_dir, dist_name):