build-iar
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese构建 IAR Embedded Workbench 工程
Building IAR Embedded Workbench Projects
适用场景
Applicable Scenarios
- 中标明
Project Profile或工作区中存在build_system: iar/.ewp文件。.eww - 用户希望对 IAR EWARM 工程执行编译、重编译或确认固件产物。
- 烧录或调试流程需要新的 (ELF)、
.out或HEX。BIN - 需要在编译前确认 IAR 环境是否就绪(iarbuild.exe、工具链)。
- indicates
Project Profileor there arebuild_system: iar/.ewpfiles in the workspace..eww - Users want to compile, recompile, or confirm firmware artifacts for IAR EWARM projects.
- New (ELF),
.out, orHEXfiles are required for programming or debugging processes.BIN - Need to confirm if the IAR environment is ready (iarbuild.exe, toolchain) before compilation.
必要输入
Required Inputs
- 工作区路径或 工程文件路径,或一份已有的
.ewp。Project Profile - 可选的配置名称(configuration)和 IAR 安装路径。
- Workspace path or project file path, or an existing
.ewp.Project Profile - Optional configuration name and IAR installation path.
自动探测
Auto Detection
- 脚本自动搜索常见 IAR 安装路径和环境变量(、
IAR_ROOT)定位 iarbuild.exe。EWARM_ROOT - 解析 工程文件中的 configuration 列表,提取工具链(ARM/RISCV)、芯片型号、输出目录和输出文件名。
.ewp - 若未指定配置,默认使用工程中的第一个 configuration。
- 在输出目录中搜索 .out(ELF)、HEX、BIN 产物,按 排序。
ELF > HEX > BIN - 若存在多个同样合理的工程文件或配置,列出候选而不是静默猜测。
- The script automatically searches common IAR installation paths and environment variables (,
IAR_ROOT) to locate iarbuild.exe.EWARM_ROOT - Parses the configuration list in the project file to extract toolchain (ARM/RISCV), chip model, output directory, and output file name.
.ewp - If no configuration is specified, the first configuration in the project is used by default.
- Searches for .out (ELF), HEX, BIN artifacts in the output directory, sorted by .
ELF > HEX > BIN - If multiple equally valid project files or configurations exist, lists candidates instead of making silent guesses.
执行步骤
Execution Steps
- 先阅读 references/usage.md,确认本次是环境探测、工程扫描、列出配置,还是执行编译。
- 若不确定环境是否就绪,先运行自带脚本 scripts/iar_builder.py 的 模式确认。
--detect - 若不确定工程文件位置,使用 搜索工作区。
--scan - 使用 确认可用配置,再用
--list-configs --project X.ewp+--project执行编译。--config - 读取脚本输出的构建结果和产物扫描报告,重点关注首选产物(.out/ELF > HEX > BIN)、错误/警告统计和失败分类。
- 将构建配置、产物路径、芯片型号和工具链信息写回 ,并在需要时交给下游 skill。
Project Profile
- First read references/usage.md to confirm whether this is environment detection, project scanning, listing configurations, or executing compilation.
- If unsure whether the environment is ready, first run the mode of the built-in script scripts/iar_builder.py to confirm.
--detect - If unsure of the project file location, use to search the workspace.
--scan - Use to confirm available configurations, then use
--list-configs --project X.ewp+--projectto execute compilation.--config - Read the build results and artifact scan report output by the script, focusing on the preferred artifacts (.out/ELF > HEX > BIN), error/warning statistics, and failure categories.
- Write the build configuration, artifact path, chip model, and toolchain information back to , and pass it to downstream skills when needed.
Project Profile
失败分流
Failure Diversion
- 当 IAR 未安装或 iarbuild.exe 不可用时,返回 。
environment-missing - 当工程文件损坏、配置名无效或编译因配置问题失败时,返回 。
project-config-error - 当编译看似成功但未找到可烧录或可调试产物时,返回 。
artifact-missing - 当存在多个同样合理的工程文件或配置,且任意选择都不安全时,返回 。
ambiguous-context
- Returns when IAR is not installed or iarbuild.exe is unavailable.
environment-missing - Returns when the project file is corrupted, the configuration name is invalid, or compilation fails due to configuration issues.
project-config-error - Returns when compilation appears successful but no programmable or debuggable artifacts are found.
artifact-missing - Returns when multiple equally valid project files or configurations exist and any selection is unsafe.
ambiguous-context
平台说明
Platform Notes
- IAR Embedded Workbench 仅在 Windows 上原生运行,iarbuild.exe 命令行编译需要 Windows 环境。
- 自带脚本在非 Windows 平台上仍可执行工程解析()、工程扫描(
--list-configs)和产物扫描(--scan),但实际编译会被阻塞。--scan-artifacts - 输出中的产物路径应保持为绝对路径,方便下游烧录和调试 skill 直接复用。
- IAR Embedded Workbench runs natively only on Windows, and iarbuild.exe command-line compilation requires a Windows environment.
- The built-in script can still perform project parsing (), project scanning (
--list-configs), and artifact scanning (--scan) on non-Windows platforms, but actual compilation will be blocked.--scan-artifacts - Artifact paths in the output should remain absolute paths for direct reuse by downstream programming and debugging skills.
输出约定
Output Conventions
- 输出编译命令、工程文件、配置名、芯片型号、工具链和首选产物路径。
- 输出错误和警告统计,以及关键编译日志证据。
- 用 、
artifact_path、artifact_kind和target_mcu更新toolchain。Project Profile - 成功后推荐 或
flash-openocd。debug-gdb-openocd
- Output compilation commands, project files, configuration names, chip models, toolchains, and preferred artifact paths.
- Output error and warning statistics, as well as key compilation log evidence.
- Update with
Project Profile,artifact_path,artifact_kind, andtarget_mcu.toolchain - Recommend or
flash-openocdafter success.debug-gdb-openocd
交接关系
Handover Relationships
- 当下一步意图是给硬件烧录程序时,将成功构建结果交给 。
flash-openocd - 当下一步需要符号信息或调试会话时,将成功构建结果交给 。
debug-gdb-openocd
- When the next step is to program hardware, pass the successful build result to .
flash-openocd - When the next step requires symbol information or a debugging session, pass the successful build result to .
debug-gdb-openocd