Skip to content

Commit f82ddca

Browse files
committed
[action/ci] add qemu-pre-build-and-post-build for RT_SMART build
1 parent 7125e7b commit f82ddca

File tree

4 files changed

+166
-14
lines changed

4 files changed

+166
-14
lines changed

.github/ALL_BSP_COMPILE.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"RTT_TOOL_CHAIN": "sourcery-arm",
7070
"SUB_RTT_BSP": [
7171
"phytium/aarch32",
72-
"qemu-vexpress-a9",
7372
"airm2m/air32f103",
7473
"acm32/acm32f0x0-nucleo",
7574
"acm32/acm32f0x0-nucleo",
@@ -449,6 +448,14 @@
449448
"nrf5x/nrf52840",
450449
"nrf5x/nrf5340"
451450
]
451+
},
452+
{
453+
"RTT_BSP": "arm-none-bsp-smart",
454+
"RTT_TOOL_CHAIN": "sourcery-arm",
455+
"RTT_SMART_TOOL_CHAIN": "arm-linux-musleabi",
456+
"SUB_RTT_BSP": [
457+
"qemu-vexpress-a9"
458+
]
452459
}
453460
]
454461
}

.github/workflows/bsp_buildings.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ jobs:
208208
pip3 install esptool
209209
echo "RTT_EXEC_PATH=/opt/riscv32-esp-elf/bin" >> $GITHUB_ENV
210210
211+
- name: Install Arm Musl ToolChains
212+
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && matrix.legs.RTT_SMART_TOOL_CHAIN == 'arm-linux-musleabi' && success() }}
213+
shell: bash
214+
run: |
215+
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2
216+
sudo tar xjf arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
217+
/opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin/arm-linux-musleabi-gcc --version
218+
211219
- name: Install Simulator Tools
212220
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'gcc' && success() }}
213221
run: |
Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
bsp_board_info:
2+
arch: arm
3+
toolchain: arm-none-eabi-gcc
4+
pre_build: |
5+
scons --version
6+
build_cmd: |
7+
scons -j8
8+
post_build: |
9+
scons --version
10+
run_cmd: ./qemu-nographic.sh
11+
qemu_flag: true
112
# ------ PERIPHERAL CI ------
213
peripheral.EMAC:
314
kconfig:
@@ -9,15 +20,39 @@ peripheral.LVGL:
920
- CONFIG_BSP_USING_LVGL=y
1021

1122
# ------ online-packages CI ------
23+
online-packages.tools.coremark:
24+
kconfig:
25+
- CONFIG_PKG_USING_COREMARK=y
26+
- CONFIG_COREMARK_ITERATIONS=36000
27+
pre_build: |
28+
scons --version
29+
build_cmd: |
30+
scons -j8
31+
post_build: |
32+
scons --version
33+
ci_build_run_flag : true
34+
buildcheckresult: "core_main" #检查编译的log中是否有匹配字
35+
msh_cmd: |
36+
ps
37+
version
38+
core_mark
39+
msh_cmd_timeout: 60
40+
checkresult: 'CoreMark 1.0' #检查执行过程中的log是否有匹配字
41+
1242
online-packages.misc.entertainment.tetris:
1343
kconfig:
1444
- CONFIG_PKG_USING_TETRIS=y
1545
online-packages.misc.entertainment.2048:
1646
kconfig:
1747
- CONFIG_PKG_USING_2048=y
18-
online-packages.ai.llmchat:
48+
# ------ RT_SMART PART ------
49+
rt_smart.base:
50+
env:
51+
RTT_CC_PREFIX: arm-linux-musleabi-
52+
RTT_EXEC_PATH: /opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin
53+
pre_build: |
54+
echo $RTT_CC_PREFIX
1955
kconfig:
20-
- CONFIG_WEBCLIENT_USING_MBED_TLS=y
21-
- CONFIG_BSP_DRV_EMAC=y
22-
- CONFIG_PKG_USING_LLMCHAT=y
23-
- CONFIG_PKG_LLM_API_KEY="sk-xxxxxx"
56+
- CONFIG_RT_USING_SMART=y
57+
- CONFIG_RT_USING_MEMHEAP=y
58+
- CONFIG_RT_USING_DFS_V2=y

tools/ci/bsp_buildings.py

Lines changed: 110 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import subprocess
2+
import threading
3+
import time
4+
import logging
5+
import sys
16
import os
27
import shutil
38
import re
@@ -36,7 +41,7 @@ def run_cmd(cmd, output_info=True):
3641
return output_str_list, res
3742

3843

39-
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,bsp_build_env=None):
4045
"""
4146
build bsp.
4247
@@ -56,21 +61,41 @@ def build_bsp(bsp, scons_args='',name='default'):
5661
5762
"""
5863
success = True
64+
# 设置环境变量
65+
if bsp_build_env is not None:
66+
print("Setting environment variables:")
67+
for key, value in bsp_build_env.items():
68+
print(f"{key}={value}")
69+
os.environ[key] = value # 设置环境变量
5970
os.chdir(rtt_root)
6071
os.makedirs(f'{rtt_root}/output/bsp/{bsp}', exist_ok=True)
6172
if os.path.exists(f"{rtt_root}/bsp/{bsp}/Kconfig"):
6273
os.chdir(rtt_root)
63-
run_cmd(f'scons -C bsp/{bsp} --pyconfig-silent', output_info=False)
74+
run_cmd(f'scons -C bsp/{bsp} --pyconfig-silent', output_info=True)
6475

6576
os.chdir(f'{rtt_root}/bsp/{bsp}')
66-
run_cmd('pkgs --update-force', output_info=False)
77+
run_cmd('pkgs --update-force', output_info=True)
6778
run_cmd('pkgs --list')
6879

6980
nproc = multiprocessing.cpu_count()
81+
if pre_build_commands is not None:
82+
print("Pre-build commands:")
83+
print(pre_build_commands)
84+
for command in pre_build_commands:
85+
print(command)
86+
output, returncode = run_cmd(command, output_info=True)
87+
print(output)
88+
if returncode != 0:
89+
print(f"Pre-build command failed: {command}")
90+
print(output)
7091
os.chdir(rtt_root)
92+
# scons 编译命令
7193
cmd = f'scons -C bsp/{bsp} -j{nproc} {scons_args}' # --debug=time for debug time
72-
__, res = run_cmd(cmd, output_info=True)
73-
94+
output, res = run_cmd(cmd, output_info=True)
95+
if build_check_result is not None:
96+
if res != 0 or not check_output(output, build_check_result):
97+
print("Build failed or build check result not found")
98+
print(output)
7499
if res != 0:
75100
success = False
76101
else:
@@ -83,6 +108,13 @@ def build_bsp(bsp, scons_args='',name='default'):
83108
shutil.copy(file, f'{rtt_root}/output/bsp/{bsp}/{name.replace("/", "_")}.{file_type[2:]}')
84109

85110
os.chdir(f'{rtt_root}/bsp/{bsp}')
111+
if post_build_command is not None:
112+
for command in post_build_command:
113+
output, returncode = run_cmd(command, output_info=True)
114+
print(output)
115+
if returncode != 0:
116+
print(f"Post-build command failed: {command}")
117+
print(output)
86118
run_cmd('scons -c', output_info=False)
87119

88120
return success
@@ -158,7 +190,17 @@ def build_bsp_attachconfig(bsp, attach_file):
158190

159191
return res
160192

193+
def check_output(output, check_string):
194+
"""检查输出中是否包含指定字符串"""
195+
output_str = ''.join(output) if isinstance(output, list) else str(output)
196+
flag = check_string in output_str
197+
if flag == True:
198+
print('Success: find string ' + check_string)
199+
else:
200+
print(output)
201+
print(f"::error:: can not find string {check_string} output: {output_str}")
161202

203+
return flag
162204
if __name__ == "__main__":
163205
"""
164206
build all bsp and attach config.
@@ -169,10 +211,12 @@ def build_bsp_attachconfig(bsp, attach_file):
169211
"""
170212
failed = 0
171213
count = 0
214+
ci_build_run_flag = False
215+
qemu_timeout_second = 50
172216

173217
rtt_root = os.getcwd()
174218
srtt_bsp = os.getenv('SRTT_BSP').split(',')
175-
219+
print(srtt_bsp)
176220
for bsp in srtt_bsp:
177221
count += 1
178222
print(f"::group::Compiling BSP: =={count}=== {bsp} ====")
@@ -207,26 +251,80 @@ def build_bsp_attachconfig(bsp, attach_file):
207251
continue
208252

209253
config_file = os.path.join(rtt_root, 'bsp', bsp, '.config')
210-
254+
# 在使用 pre_build_commands 之前,确保它被定义
255+
pre_build_commands = None
256+
build_command = None
257+
post_build_command = None
258+
qemu_command = None
259+
build_check_result = None
260+
commands = None
261+
check_result = None
262+
bsp_build_env = None
211263
for projects in yml_files_content:
212264
for name, details in projects.items():
265+
# 如果是bsp_board_info,读取基本的信息
266+
if(name == 'bsp_board_info'):
267+
print(details)
268+
pre_build_commands = details.get("pre_build").splitlines()
269+
build_command = details.get("build_cmd").splitlines()
270+
post_build_command = details.get("post_build").splitlines()
271+
qemu_command = details.get("run_cmd")
272+
273+
if details.get("kconfig") is not None:
274+
if details.get("buildcheckresult") is not None:
275+
build_check_result = details.get("buildcheckresult")
276+
else:
277+
build_check_result = None
278+
if details.get("msh_cmd") is not None:
279+
commands = details.get("msh_cmd").splitlines()
280+
else:
281+
msh_cmd = None
282+
if details.get("checkresult") is not None:
283+
check_result = details.get("checkresult")
284+
else:
285+
check_result = None
286+
if details.get("ci_build_run_flag") is not None:
287+
ci_build_run_flag = details.get("ci_build_run_flag")
288+
else:
289+
ci_build_run_flag = None
290+
if details.get("pre_build") is not None:
291+
pre_build_commands = details.get("pre_build").splitlines()
292+
if details.get("env") is not None:
293+
bsp_build_env = details.get("env")
294+
else:
295+
bsp_build_env = None
296+
if details.get("build_cmd") is not None:
297+
build_command = details.get("build_cmd").splitlines()
298+
else:
299+
build_command = None
300+
if details.get("post_build") is not None:
301+
post_build_command = details.get("post_build").splitlines()
302+
if details.get("run_cmd") is not None:
303+
qemu_command = details.get("run_cmd")
304+
else:
305+
qemu_command = None
213306
count += 1
214307
config_bacakup = config_file+'.origin'
215308
shutil.copyfile(config_file, config_bacakup)
309+
#加载yml中的配置放到.config文件
216310
with open(config_file, 'a') as destination:
217311
if details.get("kconfig") is None:
312+
#如果没有Kconfig,读取下一个配置
218313
continue
219314
if(projects.get(name) is not None):
315+
# 获取Kconfig中所有的信息
220316
detail_list=get_details_and_dependencies([name],projects)
221317
for line in detail_list:
222318
destination.write(line + '\n')
223319
scons_arg=[]
320+
#如果配置中有scons_arg
224321
if details.get('scons_arg') is not None:
225322
for line in details.get('scons_arg'):
226323
scons_arg.append(line)
227324
scons_arg_str=' '.join(scons_arg) if scons_arg else ' '
228325
print(f"::group::\tCompiling yml project: =={count}==={name}=scons_arg={scons_arg_str}==")
229-
res = build_bsp(bsp, scons_arg_str,name=name)
326+
# #开始编译bsp
327+
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,bsp_build_env =bsp_build_env)
230328
if not res:
231329
print(f"::error::build {bsp} {name} failed.")
232330
add_summary(f'\t- ❌ build {bsp} {name} failed.')
@@ -235,11 +333,15 @@ def build_bsp_attachconfig(bsp, attach_file):
235333
add_summary(f'\t- ✅ build {bsp} {name} success.')
236334
print("::endgroup::")
237335

336+
238337
shutil.copyfile(config_bacakup, config_file)
239338
os.remove(config_bacakup)
240339

340+
341+
241342
attach_dir = os.path.join(rtt_root, 'bsp', bsp, '.ci/attachconfig')
242343
attach_list = []
344+
#这里是旧的文件方式
243345
for root, dirs, files in os.walk(attach_dir):
244346
for file in files:
245347
if file.endswith('attach'):

0 commit comments

Comments
 (0)