Skip to content

Commit 63b7065

Browse files
committed
add fixed code
1 parent df8056c commit 63b7065

File tree

2 files changed

+32
-60
lines changed

2 files changed

+32
-60
lines changed

bsp/qemu-vexpress-a9/.ci/attachconfig/ci.attachconfig.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ bsp_board_info:
22
arch: arm
33
toolchain: arm-none-eabi-gcc
44
pre_build: |
5-
scons -c
5+
scons --version
66
build_cmd: |
77
scons -j8
88
post_build: |
@@ -14,7 +14,7 @@ pkg.tools.coremark:
1414
- CONFIG_PKG_USING_COREMARK=y
1515
- CONFIG_COREMARK_ITERATIONS=36000
1616
pre_build: |
17-
scons -c
17+
scons --version
1818
build_cmd: |
1919
scons -j8
2020
post_build: |
@@ -49,5 +49,4 @@ online-packages.ai.llmchat:
4949
- CONFIG_WEBCLIENT_USING_MBED_TLS=y
5050
- CONFIG_BSP_DRV_EMAC=y
5151
- CONFIG_PKG_USING_LLMCHAT=y
52-
- CONFIG_PKG_LLM_API_KEY="sk-xxxxxx"
53-
52+
- CONFIG_PKG_LLM_API_KEY="sk-xxxxxx"

tools/ci/bsp_buildings.py

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def run_cmd(cmd, output_info=True):
4141
return output_str_list, res
4242

4343

44-
def build_bsp(bsp, scons_args='',name='default'):
44+
def build_bsp(bsp, scons_args='',name='default', pre_build_commands=None, post_build_command=None,build_check_result = None):
4545
"""
4646
build bsp.
4747
@@ -65,17 +65,29 @@ def build_bsp(bsp, scons_args='',name='default'):
6565
os.makedirs(f'{rtt_root}/output/bsp/{bsp}', exist_ok=True)
6666
if os.path.exists(f"{rtt_root}/bsp/{bsp}/Kconfig"):
6767
os.chdir(rtt_root)
68-
run_cmd(f'scons -C bsp/{bsp} --pyconfig-silent', output_info=False)
68+
run_cmd(f'scons -C bsp/{bsp} --pyconfig-silent', output_info=True)
6969

7070
os.chdir(f'{rtt_root}/bsp/{bsp}')
71-
run_cmd('pkgs --update-force', output_info=False)
71+
run_cmd('pkgs --update-force', output_info=True)
7272
run_cmd('pkgs --list')
7373

7474
nproc = multiprocessing.cpu_count()
75+
if pre_build_commands is not None:
76+
for command in pre_build_commands:
77+
print(command)
78+
output, returncode = run_cmd(command, output_info=True)
79+
print(output)
80+
if returncode != 0:
81+
print(f"Pre-build command failed: {command}")
82+
print(output)
7583
os.chdir(rtt_root)
84+
# scons 编译命令
7685
cmd = f'scons -C bsp/{bsp} -j{nproc} {scons_args}' # --debug=time for debug time
77-
__, res = run_cmd(cmd, output_info=True)
78-
86+
output, res = run_cmd(cmd, output_info=True)
87+
if build_check_result is not None:
88+
if res != 0 or not check_output(output, build_check_result):
89+
print("Build failed or build check result not found")
90+
print(output)
7991
if res != 0:
8092
success = False
8193
else:
@@ -88,6 +100,13 @@ def build_bsp(bsp, scons_args='',name='default'):
88100
shutil.copy(file, f'{rtt_root}/output/bsp/{bsp}/{name.replace("/", "_")}.{file_type[2:]}')
89101

90102
os.chdir(f'{rtt_root}/bsp/{bsp}')
103+
if post_build_command is not None:
104+
for command in post_build_command:
105+
output, returncode = run_cmd(command, output_info=True)
106+
print(output)
107+
if returncode != 0:
108+
print(f"Post-build command failed: {command}")
109+
print(output)
91110
run_cmd('scons -c', output_info=False)
92111

93112
return success
@@ -281,11 +300,12 @@ def run(self,commands):
281300

282301
def check_output(output, check_string):
283302
"""检查输出中是否包含指定字符串"""
284-
flag = check_string in output
285303
output_str = ''.join(output) if isinstance(output, list) else str(output)
304+
flag = check_string in output_str
286305
if flag == True:
287-
print('find string ' + check_string)
306+
print('Success: find string ' + check_string)
288307
else:
308+
print(output)
289309
print(f"::error:: can not find string {check_string} output: {output_str}")
290310

291311
return flag
@@ -395,55 +415,8 @@ def check_output(output, check_string):
395415
scons_arg_str=' '.join(scons_arg) if scons_arg else ' '
396416
print(f"::group::\tCompiling yml project: =={count}==={name}=scons_arg={scons_arg_str}==")
397417

398-
#开始编译bsp
399-
res = build_bsp(bsp, scons_arg_str,name=name)
400-
401-
if not res:
402-
print(f"::error::build {bsp} {name} failed.")
403-
add_summary(f'\t- ❌ build {bsp} {name} failed.')
404-
failed += 1
405-
else:
406-
add_summary(f'\t- ✅ build {bsp} {name} success.')
407-
print("::endgroup::")
408-
409-
# print(commands)
410-
# print(check_result)
411-
# print(build_check_result)
412-
# print(qemu_command)
413-
# print(pre_build_commands)
414-
# print(ci_build_run_flag)
415-
416-
#执行编译前的命令
417-
if pre_build_commands is not None:
418-
for command in pre_build_commands:
419-
output, returncode = run_cmd(command, output_info=False)
420-
print(output)
421-
if returncode != 0:
422-
print(f"Pre-build command failed: {command}")
423-
print(output)
424-
#执行编译命令
425-
if build_command is not None:
426-
for command in build_command:
427-
output, returncode = run_cmd(command, output_info=False)
428-
print(output)
429-
if returncode != 0 or not check_output(output, build_check_result):
430-
print(f"build command failed: {command}")
431-
print(output)
432-
#执行编译后的命令
433-
if post_build_command is not None:
434-
for command in post_build_command:
435-
output, returncode = run_cmd(command, output_info=False)
436-
print(output)
437-
if returncode != 0:
438-
print(f"Post-build command failed: {command}")
439-
print(output)
440-
#执行qemu中的执行命令,这个暂时先注释掉,ci跑不起来
441-
# if ci_build_run_flag is True:
442-
# print(qemu_command)
443-
# #exit(1)
444-
# print(os.getcwd())
445-
# qemu_manager = QemuManager(qemu_cmd=qemu_command, idle_timeout=qemu_timeout_second,checkresult=check_result)
446-
# qemu_manager.run(commands)
418+
# #开始编译bsp
419+
res = build_bsp(bsp, scons_arg_str,name=name,pre_build_commands=pre_build_commands,post_build_command=post_build_command,build_check_result=build_check_result)
447420

448421
shutil.copyfile(config_bacakup, config_file)
449422
os.remove(config_bacakup)

0 commit comments

Comments
 (0)