@@ -36,7 +36,7 @@ def run_cmd(cmd, output_info=True):
3636 return output_str_list , res
3737
3838
39- def build_bsp (bsp , scons_args = '' ):
39+ def build_bsp (bsp , scons_args = '' , name = 'default' ):
4040 """
4141 build bsp.
4242
@@ -57,6 +57,7 @@ def build_bsp(bsp, scons_args=''):
5757 """
5858 success = True
5959 os .chdir (rtt_root )
60+ os .makedirs (f'{ rtt_root } /output/bsp/{ bsp } ' , exist_ok = True )
6061 if os .path .exists (f"{ rtt_root } /bsp/{ bsp } /Kconfig" ):
6162 os .chdir (rtt_root )
6263 run_cmd (f'scons -C bsp/{ bsp } --pyconfig-silent' , output_info = False )
@@ -67,18 +68,23 @@ def build_bsp(bsp, scons_args=''):
6768
6869 nproc = multiprocessing .cpu_count ()
6970 os .chdir (rtt_root )
70- cmd = f'scons -C bsp/{ bsp } -j{ nproc } { scons_args } --debug=time'
71+ cmd = f'scons -C bsp/{ bsp } -j{ nproc } { scons_args } ' # --debug=time for debug time
7172 __ , res = run_cmd (cmd , output_info = True )
7273
7374 if res != 0 :
7475 success = False
76+ else :
77+ #拷贝当前的文件夹下面的所有以elf结尾的文件拷贝到rt-thread/output文件夹下
78+ import glob
79+ # 拷贝编译生成的文件到output目录,文件拓展为 elf,bin,hex
80+ for file_type in ['*.elf' , '*.bin' , '*.hex' ]:
81+ files = glob .glob (f'{ rtt_root } /bsp/{ bsp } /{ file_type } ' )
82+ for file in files :
83+ shutil .copy (file , f'{ rtt_root } /output/bsp/{ bsp } /{ name .replace ("/" , "_" )} .{ file_type [2 :]} ' )
7584
7685 os .chdir (f'{ rtt_root } /bsp/{ bsp } ' )
7786 run_cmd ('scons -c' , output_info = False )
7887
79- #pkg_dir = os.path.join(rtt_root, 'bsp', bsp, 'packages')
80- #shutil.rmtree(pkg_dir, ignore_errors=True)
81-
8288 return success
8389
8490
@@ -145,7 +151,7 @@ def build_bsp_attachconfig(bsp, attach_file):
145151
146152 scons_args = check_scons_args (attach_path )
147153
148- res = build_bsp (bsp , scons_args )
154+ res = build_bsp (bsp , scons_args , name = attach_file )
149155
150156 shutil .copyfile (config_bacakup , config_file )
151157 os .remove (config_bacakup )
@@ -220,7 +226,7 @@ def build_bsp_attachconfig(bsp, attach_file):
220226 scons_arg .append (line )
221227 scons_arg_str = ' ' .join (scons_arg ) if scons_arg else ' '
222228 print (f"::group::\t Compiling yml project: =={ count } ==={ name } =scons_arg={ scons_arg_str } ==" )
223- res = build_bsp (bsp , scons_arg_str )
229+ res = build_bsp (bsp , scons_arg_str , name = name )
224230 if not res :
225231 print (f"::error::build { bsp } { name } failed." )
226232 add_summary (f'\t - ❌ build { bsp } { name } failed.' )
0 commit comments