@@ -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
@@ -72,13 +72,17 @@ def build_bsp(bsp, scons_args=''):
7272
7373 if res != 0 :
7474 success = False
75+ #拷贝当前的文件夹下面的所有以elf结尾的文件拷贝到rt-thread/output文件夹下
76+ import glob
77+ # 拷贝编译生成的文件到output目录,文件拓展为 elf,bin,hex
78+ for file_type in ['*.elf' , '*.bin' , '*.hex' ]:
79+ files = glob .glob (f'{ rtt_root } /bsp/{ bsp } /{ file_type } ' )
80+ for file in files :
81+ shutil .copy (file , f'{ rtt_root } /output/bsp/{ bsp } /{ name } .{ file_type [2 :]} ' )
7582
7683 os .chdir (f'{ rtt_root } /bsp/{ bsp } ' )
7784 run_cmd ('scons -c' , output_info = False )
7885
79- #pkg_dir = os.path.join(rtt_root, 'bsp', bsp, 'packages')
80- #shutil.rmtree(pkg_dir, ignore_errors=True)
81-
8286 return success
8387
8488
@@ -145,7 +149,7 @@ def build_bsp_attachconfig(bsp, attach_file):
145149
146150 scons_args = check_scons_args (attach_path )
147151
148- res = build_bsp (bsp , scons_args )
152+ res = build_bsp (bsp , scons_args , name = attach_file . tostring () )
149153
150154 shutil .copyfile (config_bacakup , config_file )
151155 os .remove (config_bacakup )
@@ -220,7 +224,7 @@ def build_bsp_attachconfig(bsp, attach_file):
220224 scons_arg .append (line )
221225 scons_arg_str = ' ' .join (scons_arg ) if scons_arg else ' '
222226 print (f"::group::\t Compiling yml project: =={ count } ==={ name } =scons_arg={ scons_arg_str } ==" )
223- res = build_bsp (bsp , scons_arg_str )
227+ res = build_bsp (bsp , scons_arg_str , name = name )
224228 if not res :
225229 print (f"::error::build { bsp } { name } failed." )
226230 add_summary (f'\t - ❌ build { bsp } { name } failed.' )
0 commit comments