summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHao Zhu <[email protected]>2018-12-14 08:47:54 +0800
committerHao Zhu <[email protected]>2018-12-14 08:47:54 +0800
commit2fbced6f218da3cb809252c9ae248d08ed7838d3 (patch)
treed64113744193106afbe8c109435077e80cd27b3f /tools
parent5053e744a3136171bc8840f23b2ae9b7abc5c102 (diff)
parent698f9a91bdb4577f0d1e7823a7ece7863afd055b (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'tools')
-rw-r--r--tools/building.py3
-rw-r--r--tools/mkdist.py38
2 files changed, 41 insertions, 0 deletions
diff --git a/tools/building.py b/tools/building.py
index ba6c5000e4..eb2da2fab9 100644
--- a/tools/building.py
+++ b/tools/building.py
@@ -810,6 +810,9 @@ def EndBuilding(target, program = None):
Env['target'] = program
Env['project'] = Projects
+ if hasattr(rtconfig, 'BSP_LIBRARY_TYPE'):
+ Env['bsp_lib_type'] = rtconfig.BSP_LIBRARY_TYPE
+
Env.AddPostAction(target, rtconfig.POST_ACTION)
# Add addition clean files
Clean(target, 'cconfig.h')
diff --git a/tools/mkdist.py b/tools/mkdist.py
index eef6bfd118..e927417fc4 100644
--- a/tools/mkdist.py
+++ b/tools/mkdist.py
@@ -122,6 +122,24 @@ def bsp_update_kconfig(dist_dir):
line = line[0:position] + 'default: "rt-thread"\n'
found = 0
f.write(line)
+
+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
+ if line.find('../libraries') != -1 and found:
+ position = line.find('../libraries')
+ line = line[0:position] + 'libraries/Kconfig"\n'
+ found = 0
+ f.write(line)
def bs_update_ide_project(bsp_root, rtt_root):
import subprocess
@@ -169,6 +187,15 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env):
print('=> %s' % os.path.basename(BSP_ROOT))
bsp_copy_files(BSP_ROOT, dist_dir)
+ # copy stm32 bsp libiary files
+ if os.path.basename(os.path.dirname(BSP_ROOT)) == 'stm32':
+ print("=> copy stm32 bsp library")
+ library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries')
+ library_dir = os.path.join(dist_dir, 'libraries')
+ bsp_copy_files(os.path.join(library_path, 'HAL_Drivers'), os.path.join(library_dir, 'HAL_Drivers'))
+ bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type']))
+ shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
+
# get all source files from program
for item in program:
walk_children(item)
@@ -260,6 +287,7 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env):
bsp_update_sconstruct(dist_dir)
# change RTT_ROOT in Kconfig
bsp_update_kconfig(dist_dir)
+ bsp_update_kconfig_library(dist_dir)
# update all project files
bs_update_ide_project(dist_dir, target_path)
@@ -280,6 +308,15 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
print('=> %s' % os.path.basename(BSP_ROOT))
bsp_copy_files(BSP_ROOT, dist_dir)
+ # copy stm32 bsp libiary files
+ if os.path.basename(os.path.dirname(BSP_ROOT)) == 'stm32':
+ print("=> copy stm32 bsp library")
+ library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries')
+ library_dir = os.path.join(dist_dir, 'libraries')
+ bsp_copy_files(os.path.join(library_path, 'HAL_Drivers'), os.path.join(library_dir, 'HAL_Drivers'))
+ bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type']))
+ shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
+
# copy tools directory
print('=> components')
do_copy_folder(os.path.join(RTT_ROOT, 'components'), os.path.join(target_path, 'components'))
@@ -316,6 +353,7 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
bsp_update_sconstruct(dist_dir)
# change RTT_ROOT in Kconfig
bsp_update_kconfig(dist_dir)
+ bsp_update_kconfig_library(dist_dir)
# update all project files
bs_update_ide_project(dist_dir, target_path)