@@ -122,6 +122,24 @@ def bsp_update_kconfig(dist_dir):
122122 line = line [0 :position ] + 'default: "rt-thread"\n '
123123 found = 0
124124 f .write (line )
125+
126+ def bsp_update_kconfig_library (dist_dir ):
127+ # change RTT_ROOT in Kconfig
128+ if not os .path .isfile (os .path .join (dist_dir , 'Kconfig' )):
129+ return
130+
131+ with open (os .path .join (dist_dir , 'Kconfig' ), 'r' ) as f :
132+ data = f .readlines ()
133+ with open (os .path .join (dist_dir , 'Kconfig' ), 'w' ) as f :
134+ found = 0
135+ for line in data :
136+ if line .find ('RTT_ROOT' ) != - 1 :
137+ found = 1
138+ if line .find ('../libraries' ) != - 1 and found :
139+ position = line .find ('../libraries' )
140+ line = line [0 :position ] + 'libraries/Kconfig"\n '
141+ found = 0
142+ f .write (line )
125143
126144def bs_update_ide_project (bsp_root , rtt_root ):
127145 import subprocess
@@ -169,6 +187,21 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env):
169187 print ('=> %s' % os .path .basename (BSP_ROOT ))
170188 bsp_copy_files (BSP_ROOT , dist_dir )
171189
190+ # copy stm32 bsp libiary files
191+ if os .path .basename (os .path .dirname (BSP_ROOT )) == 'stm32' :
192+ print ("=> copy stm32 bsp library" )
193+ library_path = os .path .join (os .path .dirname (BSP_ROOT ), 'libraries' )
194+ library_dir = os .path .join (dist_dir , 'libraries' )
195+ bsp_copy_files (os .path .join (library_path , 'HAL_Drivers' ), os .path .join (library_dir , 'HAL_Drivers' ))
196+ bsp_copy_files (os .path .join (library_path , Env ['bsp_lib_type' ]), os .path .join (library_dir , Env ['bsp_lib_type' ]))
197+ shutil .copyfile (os .path .join (library_path , 'Kconfig' ), os .path .join (library_dir , 'Kconfig' ))
198+
199+ # do bsp special dist handle
200+ if 'dist_handle' in Env :
201+ print ("=> start dist handle" )
202+ dist_handle = Env ['dist_handle' ]
203+ dist_handle (BSP_ROOT )
204+
172205 # get all source files from program
173206 for item in program :
174207 walk_children (item )
@@ -260,6 +293,7 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env):
260293 bsp_update_sconstruct (dist_dir )
261294 # change RTT_ROOT in Kconfig
262295 bsp_update_kconfig (dist_dir )
296+ bsp_update_kconfig_library (dist_dir )
263297 # update all project files
264298 bs_update_ide_project (dist_dir , target_path )
265299
@@ -280,6 +314,21 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
280314 print ('=> %s' % os .path .basename (BSP_ROOT ))
281315 bsp_copy_files (BSP_ROOT , dist_dir )
282316
317+ # copy stm32 bsp libiary files
318+ if os .path .basename (os .path .dirname (BSP_ROOT )) == 'stm32' :
319+ print ("=> copy stm32 bsp library" )
320+ library_path = os .path .join (os .path .dirname (BSP_ROOT ), 'libraries' )
321+ library_dir = os .path .join (dist_dir , 'libraries' )
322+ bsp_copy_files (os .path .join (library_path , 'HAL_Drivers' ), os .path .join (library_dir , 'HAL_Drivers' ))
323+ bsp_copy_files (os .path .join (library_path , Env ['bsp_lib_type' ]), os .path .join (library_dir , Env ['bsp_lib_type' ]))
324+ shutil .copyfile (os .path .join (library_path , 'Kconfig' ), os .path .join (library_dir , 'Kconfig' ))
325+
326+ # do bsp special dist handle
327+ if 'dist_handle' in Env :
328+ print ("=> start dist handle" )
329+ dist_handle = Env ['dist_handle' ]
330+ dist_handle (BSP_ROOT )
331+
283332 # copy tools directory
284333 print ('=> components' )
285334 do_copy_folder (os .path .join (RTT_ROOT , 'components' ), os .path .join (target_path , 'components' ))
@@ -316,6 +365,7 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
316365 bsp_update_sconstruct (dist_dir )
317366 # change RTT_ROOT in Kconfig
318367 bsp_update_kconfig (dist_dir )
368+ bsp_update_kconfig_library (dist_dir )
319369 # update all project files
320370 bs_update_ide_project (dist_dir , target_path )
321371
0 commit comments