-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolchains.py
More file actions
102 lines (98 loc) · 3.36 KB
/
Copy pathtoolchains.py
File metadata and controls
102 lines (98 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"""
toolchains.py — 7 种内置工具链模板
下拉选取时,前端拿到这些模板自动填充表单
"""
from typing import List, Dict
def get_builtin_templates() -> List[Dict]:
"""返回 7 种内置工具链模板"""
return [
# 1. Keil MDK (UV4)
{
"id": 1,
"name": "Keil MDK (UV4)",
"type": "keil",
"executable": r"C:\Keil_v5\UV4\UV4.exe",
"args_template": '-b -j0 -o "{output_dir}\build.log" "{project}"',
"env_vars": {},
"description": "ARM Keil MDK — UV4 命令行构建(Windows)",
"builtin": True,
},
# 2. GCC ARM
{
"id": 2,
"name": "GCC ARM (arm-none-eabi-gcc)",
"type": "gcc",
"executable": "arm-none-eabi-gcc",
"args_template": '-o "{output_dir}/firmware.elf" {sources} -T {linker_script} -mcpu=cortex-m4 -mthumb',
"env_vars": {},
"description": "GNU ARM Embedded Toolchain(交叉编译)",
"builtin": True,
},
# 3. Make
{
"id": 3,
"name": "Make + GCC",
"type": "make",
"executable": "make",
"args_template": '-C "{project_dir}" -j4 all',
"env_vars": {},
"description": "Makefile 驱动的交叉编译",
"builtin": True,
},
# 4. CMake
{
"id": 4,
"name": "CMake + Ninja",
"type": "cmake",
"executable": "cmake",
"args_template": '--build "{build_dir}" --config Release --parallel 4',
"env_vars": {"CMAKE_BUILD_TYPE": "Release"},
"description": "CMake 构建系统(Ninja/Unix Makefiles)",
"builtin": True,
},
# 5. ESP-IDF
{
"id": 5,
"name": "ESP-IDF (idf.py)",
"type": "esp_idf",
"executable": "idf.py",
"args_template": '-B "{build_dir}" build',
"env_vars": {"IDF_PATH": r"C:\esp-idf"},
"description": "乐鑫 ESP32 官方开发框架",
"builtin": True,
},
# 6. IAR
{
"id": 6,
"name": "IAR Embedded Workbench",
"type": "iar",
"executable": r"C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\bin\iarbuild.exe",
"args_template": '"{project}.ewp" -build "{config}" -log build.log',
"env_vars": {},
"description": "IAR 命令行构建(Windows)",
"builtin": True,
},
# 7. SSH 远程执行
{
"id": 7,
"name": "SSH 远程执行",
"type": "ssh",
"executable": "",
"args_template": "",
"env_vars": {
"ssh_host": "192.168.1.50",
"ssh_port": "22",
"ssh_user": "ci",
"ssh_key": r"C:\keys\id_ed25519",
"ssh_command": "cd /opt/fw && make BOARD={board}",
},
"description": "通过 SSH 在远程 Linux 编译机上执行命令",
"builtin": True,
},
]
def get_template_by_type(tc_type: str) -> Dict:
"""按 type 取模板(用于前端下拉后填充)"""
for t in get_builtin_templates():
if t["type"] == tc_type:
return t
return {}