[ci][bsp_build]attachconfig add scons args parsing (#8464)

This commit is contained in:
vacabun 2024-01-09 22:03:32 +08:00 committed by GitHub
parent 48244f25f8
commit acaa23052f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import os
import shutil
import re
import multiprocessing
@ -17,6 +18,7 @@ def run_cmd(cmd, output_info=True):
print('\033[1;32m' + cmd + '\033[0m')
output_str_list = []
res = 0
if output_info:
res = os.system(cmd + " > output.txt 2>&1")
@ -34,7 +36,7 @@ def run_cmd(cmd, output_info=True):
return output_str_list, res
def build_bsp(bsp):
def build_bsp(bsp, scons_args=''):
"""
build bsp.
@ -46,7 +48,7 @@ def build_bsp(bsp):
pkgs --list
cd {rtt_root}
scons -C bsp/{bsp} -j{nproc}
scons -C bsp/{bsp} -j{nproc} {scons_args}
cd {rtt_root}/bsp/{bsp}
scons -c > /dev/null
@ -65,7 +67,8 @@ def build_bsp(bsp):
nproc = multiprocessing.cpu_count()
os.chdir(rtt_root)
__, res = run_cmd(f'scons -C bsp/{bsp} -j{nproc}', output_info=False)
cmd = f'scons -C bsp/{bsp} -j{nproc} {scons_args}'
__, res = run_cmd(cmd, output_info=False)
if res != 0:
success = False
@ -89,6 +92,16 @@ def append_file(source_file, destination_file):
destination.write(line)
def check_scons_args(file_path):
args = []
with open(file_path, 'r') as file:
for line in file:
match = re.search(r'#\s*scons:\s*(.*)', line)
if match:
args.append(match.group(1).strip())
return ' '.join(args)
def build_bsp_attachconfig(bsp, attach_file):
"""
build bsp with attach config.
@ -111,7 +124,9 @@ def build_bsp_attachconfig(bsp, attach_file):
append_file(attach_path, config_file)
res = build_bsp(bsp)
scons_args = check_scons_args(attach_path)
res = build_bsp(bsp, scons_args)
shutil.copyfile(config_bacakup, config_file)
os.remove(config_bacakup)