SuperAPI AI Directory

build-iar

Coding & development

View repository

Updated 10-15 23:58

About this skill

Build an IAR Embedded Workbench project

Applicable scenarios

  • Project Profile is indicated in build_system: iar or a .ewp / .eww file exists in the workspace.
  • The user wants to compile, rebuild, or confirm the firmware artifacts for an IAR EWARM project.
  • The flashing or debugging flow requires a new .out(ELF)、HEX or BIN。
  • It is necessary to confirm before compiling whether the IAR environment is ready (iarbuild.exe, toolchain).

Required inputs

  • Workspace path or .ewp project file path, or an existing Project Profile。
  • Optional configuration name and IAR installation path.

Automatic detection

  • On startup, the script automatically reuses the last successful profile in the project root directory .em_skill.json as the default parameters (explicit parameters take precedence; there is no need to manually pass --resume);--resume It is only used to assert that the cache must exist; if there is no cache, it exits with a non-zero code. When there is no cache or the user explicitly requests re-detection, the script automatically falls back to a normal scan.
  • The script automatically searches common IAR installation paths and environment variables (IAR_ROOT、EWARM_ROOT) to locate iarbuild.exe.
  • Parse .ewp the configuration list in the project file, and extract the toolchain (ARM/RISCV), chip model, output directory, and output file name.
  • If no configuration is specified, the first configuration in the project is used by default.
  • Search the output directory for .out (ELF), HEX, and BIN artifacts, sorted by ELF > HEX > BIN .
  • If multiple equally reasonable project files or configurations exist, list the candidates instead of silently guessing.

Execution steps

  1. First read references/usage.md, and confirm whether this time it is environment detection, project scanning, listing configurations, or performing a build.
  2. If unsure whether the environment is ready, first run the bundled script scripts/iar_builder.py 's --detect mode to confirm.
  3. If unsure of the project file location, use --scan to search the workspace.
  4. Use --list-configs --project X.ewp to confirm the available configurations, then use --project + --config to perform the build.
  5. Read the build results and artifact scan report output by the script, focusing on the preferred artifact (.out/ELF > HEX > BIN), error/warning statistics, and failure classification.
  6. Write the build configuration, artifact paths, chip model, and toolchain information back to Project Profile, and hand it off to downstream skills when needed.

Failure triage

  • When IAR is not installed or iarbuild.exe is unavailable, return environment-missing。
  • When the project file is corrupted, the configuration name is invalid, or the build fails due to configuration issues, return project-config-error。
  • When the build appears to succeed but no flashable or debuggable artifact is found, return artifact-missing。
  • When multiple equally reasonable project files or configurations exist and choosing any of them is unsafe, return ambiguous-context。

Platform notes

  • IAR Embedded Workbench runs natively only on Windows, and iarbuild.exe command-line compilation requires a Windows environment.
  • The bundled script can still perform project parsing (--list-configs), project scanning (--scan), and artifact scanning (--scan-artifacts) on non-Windows platforms, but the actual build will be blocked.
  • The artifact path in the output should remain an absolute path, making it convenient for downstream flashing and debugging skills to reuse directly.

Output conventions

  • Output the compile command, project file, configuration name, chip model, toolchain, and preferred artifact path.
  • Output error and warning statistics, as well as key compile log evidence.
  • Use artifact_path、artifact_kind、target_mcu and toolchain to update Project Profile。
  • On success, recommend flash-openocd or debug-gdb-openocd。

Handoff relationships

  • When the next step is intended to flash a program to hardware, hand off the successful build result to flash-openocd。
  • When the next step requires symbol information or a debugging session, hand off the successful build result to debug-gdb-openocd。