Imported from 0xchaihu/nxp-mcu-build-verify (
SKILL.md). Install upstream withnpx skills add 0xchaihu/nxp-mcu-build-verify. Copyright stays with the author.
NXP MCU Build Verify
Overview
Use this skill to detect the NXP MCU project type and run build verification with the matching command-line tool only. Never fall back to GCC for IAR, Keil, or MCUXpresso IDE projects.
Workflow
- Use dry-run when you need to confirm detection, preview the exact command, or obtain a host_execution_command before requesting host execution. If the project type and execution path are already known, skip dry-run and run the real build directly.
- When the project type is already known, prefer an explicit direct invocation such as
-Type MCUXpressoVSCode -Config debuginstead of spending an extra round-trip on dry-run. Match MCUXpresso VS Code preset naming fromCMakePresets.json; keep IAR, Keil, and MCUXpresso IDE config names as defined by those tools, typicallyDebug/Release. - Real builds default to compact tool output: write the raw tool log to a system temporary log directory and print only a short summary in the console.
- Add
-FullToolOutputonly when diagnosing toolchain or project-file issues and the compact summary is insufficient. - For MCUXpresso IDE real builds, use
mcuxpressoidec.exe -nosplash --launcher.suppressErrors -application org.eclipse.cdt.managedbuilder.core.headlessbuild -data <workspace-or-temp-workspace> -build <project/config>as the default generic path for.project + .cprojectprojects. If a parent Eclipse workspace with.metadataexists, prefer that real workspace; when running from a mirrored or sandboxed workspace copy, try to resolve the matching real project under the user workspace first. Only fall back to a temporary workspace plus-importwhen no real workspace can be found. - In sandboxed or agent-run environments, explicitly refuse MCUXpresso IDE sandbox execution. Emit a direct native-tool
host_execution_command, printsandbox_execution_refused=true, and require the caller to rerun it on the host or in an unsandboxed shell. Do not first try a sandbox build, do not stop at only printing a command, and never launchmcuxpressoide.exe. - For IAR real builds in sandboxed or agent-run environments, explicitly refuse sandbox execution. Emit a direct native-tool
host_execution_command, printsandbox_execution_refused=true, and require the caller to rerun it on the host or in an unsandboxed shell. Allow at least 20 minutes before timing out once running on the host. - For Keil real builds in sandboxed or agent-run environments, explicitly refuse sandbox execution. Emit a direct native-tool
host_execution_command, printsandbox_execution_refused=true, and require the caller to rerun it on the host or in an unsandboxed shell. Prefer the real Windows user environment because sandbox usernames can invalidate user-based licenses. - For Keil, prefer
uVision.comoverUV4.exefor command-line builds. - If an IAR build is interrupted, inspect
<Config>\.ninja_log,<Config>\Exe\*.srec, and<Config>\Exe\*.outbefore concluding it failed. - If compact mode reports a native-tool stderr warning without a non-zero exit code, inspect the log or rerun with
-FullToolOutputbefore treating it as a hard failure. - For MCUXpresso VS Code projects with
CMakePresets.json, translate the selected configure preset into explicitcmake -S/-Bandcmake --buildcommands instead of callingcmake --preset. Resolveinclude,inherits,binaryDir,toolchainFile,cacheVariables, and preset environment values in PowerShell first so the build still works on machines whose CMake cannot parse newer preset versions. - For MCUXpresso VS Code real builds in sandboxed or agent-run environments, explicitly refuse to run inside the sandbox. Emit a PowerShell
host_execution_command, print that sandbox execution was refused, and require the caller to run it directly on the host. - If the script reports a missing tool, stop and install/configure that IDE toolchain; do not switch to GCC.
Commands
# Optional dry-run (detect + print command, no build)
powershell -ExecutionPolicy Bypass -File "<skill-root>\\scripts\\detect-build.ps1" -ProjectRoot "<project-path>" -DryRun
# Real build verification (compact summary + log file)
powershell -ExecutionPolicy Bypass -File "<skill-root>\\scripts\\detect-build.ps1" -ProjectRoot "<project-path>"
# Real build verification with full tool output
powershell -ExecutionPolicy Bypass -File "<skill-root>\\scripts\\detect-build.ps1" -ProjectRoot "<project-path>" -FullToolOutput
# Recommended direct build when the project type is already known
powershell -ExecutionPolicy Bypass -File "<skill-root>\\scripts\\detect-build.ps1" -ProjectRoot "<project-path>" -Type MCUXpressoVSCode -Config "debug"
# IAR host/unsandboxed build template
powershell -ExecutionPolicy Bypass -File "<skill-root>\\scripts\\detect-build.ps1" -ProjectRoot "<project-path>" -Type IAR -Config "Debug"
# Keil host/unsandboxed build template
powershell -ExecutionPolicy Bypass -File "<skill-root>\\scripts\\detect-build.ps1" -ProjectRoot "<project-path>" -Type Keil -Config "Debug"
# Explicit configuration / target (for tool-defined names such as `Debug`)
powershell -ExecutionPolicy Bypass -File "<skill-root>\\scripts\\detect-build.ps1" -ProjectRoot "<project-path>" -Config "Debug"
# MCUXpresso IDE managedbuilder headlessbuild template
powershell -ExecutionPolicy Bypass -File "<skill-root>\\scripts\\detect-build.ps1" -ProjectRoot "<project-path>" -Type MCUXpressoIDE -Config "Debug"
# Force project type when mixed markers exist
powershell -ExecutionPolicy Bypass -File "<skill-root>\\scripts\\detect-build.ps1" -ProjectRoot "<project-path>" -Type "Keil" -DryRun
Output Contract
The script always prints these keys so logs are easy to parse:
forced_type(only when-Typeis set)project_typedetected_filedetected_configs(comma-separated list of build configurations extracted from the project file)tool_pathselected_commandtool_output_modeandtool_logfor real builds in compact modepreferred_execution_mode,recommended_timeout_ms,execution_hint, and ahost_execution_commandfor IAR, Keil, MCUXpresso IDE, and MCUXpresso VS Code builds that should run on the hostkeil_tools_ini,keil_tools_ini_issue,keil_tools_ini_backup_hint, andkeil_tools_ini_repair_hintwhen Keil configuration is invalid
Failures return a non-zero exit code and include actionable guidance on the missing tool path/configuration.
Detection Rules
See references/project-markers.md for marker and command details.
Hard Rules
- Prefer the nearest detected project root.
- If multiple markers exist in the same directory, prefer: IAR > Keil > MCUXpresso IDE > MCUXpresso VS Code.
-Typecan force one type:IAR,Keil,MCUXpressoIDE,MCUXpressoVSCode(aliases:ide,vscode).- If
-Configis not provided, all project types extract available build configurations from the project file first (IAR from.ewp, Keil from.uvprojx, MCUXpresso IDE from.cproject, MCUXpresso VS Code fromCMakePresets.json). Configurations containing "debug" are tried first, then "release", then all others. If no configs are found in the project file, fall back toDebugthenRelease. - For MCUXpresso VS Code, prefer the preset/configuration spelling used in
CMakePresets.jsonin examples and direct invocations, which is often lowercase such asdebug/release. - Dry-run is optional; use it when detection is uncertain, when you need to preview commands, or when you need a
host_execution_commandfor host-side execution. If the project type and exact invocation are already known, run the real build directly. - Real builds default to compact tool output and write the raw tool log under a system temporary log directory; use
-FullToolOutputonly when detailed live output is required. - For MCUXpresso IDE, default to
mcuxpressoidec.exe -nosplash --launcher.suppressErrors -application org.eclipse.cdt.managedbuilder.core.headlessbuild -build <project/config>. Prefer the real parent workspace when.metadataexists; when running from a mirrored or sandboxed workspace copy, first resolve the matching real project/workspace under the user profile. Only then fall back to a temporary-dataworkspace plus-import <projectDir>. - For MCUXpresso IDE, emit
preferred_execution_mode=host_or_unsandboxed,recommended_timeout_ms=1200000, anexecution_hint, and a direct native-toolhost_execution_commandfor real builds. In Codex or any sandboxed/agent-run environment, emitsandbox_execution_refused=trueand refuse the real build instead of attempting it. - For MCUXpresso IDE, do not switch to
com.nxp.mcuxpresso.headless.build; that application id is not present in this installation. - For MCUXpresso IDE, pass an explicit writable temporary Eclipse
-configurationdirectory instead of relying on the default profile location. - For MCUXpresso IDE, never launch
mcuxpressoide.exe; usemcuxpressoidec.exeheadless only. - For IAR, emit
recommended_timeout_ms=1200000,preferred_execution_mode=host_or_unsandboxed, and a direct native-toolhost_execution_command; in Codex or any sandboxed/agent-run environment, emitsandbox_execution_refused=trueand refuse the real build instead of attempting it. - For IAR, treat fresh
Exe\*.srec/Exe\*.out/List\*.mapartifacts as success evidence when the wrapper exits non-zero. - For Keil, emit
preferred_execution_mode=host_or_unsandboxed, preferuVision.com, and in Codex or any sandboxed/agent-run environment emitsandbox_execution_refused=trueand refuse the real build instead of attempting it. - For Keil, validate
TOOLS.INIbefore building; if repair is needed, require explicit user confirmation and back up the original file first. - For Keil, when
TOOLS.INIis invalid, emit short repair diagnostics, but never modifyTOOLS.INIautomatically from the shared skill. - For MCUXpresso VS Code projects with
CMakePresets.json, do not invokecmake --presetorcmake --build --presetdirectly. Parse the preset files in PowerShell, resolve inherited environment/cache variables, then run explicitcmake -S <project-dir> -B <binary-dir> ...followed bycmake --build <binary-dir>so the same skill works on computers with older CMake versions. - For MCUXpresso VS Code real builds in Codex or any sandboxed/agent-run environment, emit
preferred_execution_mode=host_or_unsandboxed,recommended_timeout_ms=1200000, anexecution_hint, and a PowerShellhost_execution_command, then explicitly refuse sandbox execution instead of attempting the build. - When the translated MCUXpresso VS Code configure preset selects a Ninja generator, resolve
ninja.exefrom common MCUXpresso locations before falling back toPATH, and pass it asCMAKE_MAKE_PROGRAMif the preset did not already define one. - Do not use GCC fallback unless the project is an actual CMake-based MCUXpresso VS Code project.