build-makefile
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese构建 Makefile 工程
Build Makefile Projects
适用场景
Applicable Scenarios
- 中标明
Project Profile。build_system: makefile - 工作区存在 /
Makefile/makefile,但没有GNUmakefile、CMakeLists.txt、platformio.ini或.uvprojx。.ewp - 用户希望对裸 Makefile MCU 工程执行编译或确认固件产物。
- 烧录或调试流程需要新的 、
ELF或HEX。BIN
- specifies
Project Profile.build_system: makefile - The workspace contains /
Makefile/makefile, but noGNUmakefile,CMakeLists.txt,platformio.inior.uvprojx..ewp - Users want to compile or confirm firmware artifacts for bare Makefile MCU projects.
- New ,
ELForHEXfiles are required for flashing or debugging processes.BIN
必要输入
Required Inputs
- 工作区路径,或一份已有的 。
Project Profile - 可选的 make 目标名、额外变量(如 、
CROSS_COMPILE)、make 标志和并行任务数。MCU
- Workspace path, or an existing .
Project Profile - Optional make target name, additional variables (e.g., ,
CROSS_COMPILE), make flags, and number of parallel tasks.MCU
自动探测
Automatic Detection
- 若工作区根目录存在 /
Makefile/makefile,脚本自动识别。GNUmakefile - 解析 Makefile 变量:、
CROSS_COMPILE、CC、TARGET、MCU、BOARD、CFLAGS等。LDFLAGS - 从 前缀推断工具链家族(
CROSS_COMPILE→arm-none-eabi-,gnu-arm→riscv32-unknown-elf-,gnu-riscv→xtensa-esp32-elf-)。gnu-esp - 从 变量、
MCU标志或链接脚本名推断目标芯片。-mcpu= - 检测 /
make/gmake是否可用。mingw32-make - 若 Makefile 包含 ,提示用户使用
# Generated by CMakeskill。build-cmake
- If /
Makefile/makefileexists in the workspace root directory, the script automatically identifies it.GNUmakefile - Parse Makefile variables: ,
CROSS_COMPILE,CC,TARGET,MCU,BOARD,CFLAGS, etc.LDFLAGS - Infer toolchain family from prefix (
CROSS_COMPILE→arm-none-eabi-,gnu-arm→riscv32-unknown-elf-,gnu-riscv→xtensa-esp32-elf-).gnu-esp - Infer target chip from variable,
MCUflag or linker script name.-mcpu= - Detect if /
make/gmakeis available.mingw32-make - If the Makefile contains , prompt the user to use the
# Generated by CMakeskill.build-cmake
执行步骤
Execution Steps
- 先阅读 references/usage.md,确认本次是环境探测、解析 Makefile、列出目标、执行构建,还是仅扫描产物。
- 若不确定环境是否就绪,先运行自带脚本 scripts/makefile_builder.py 的 模式确认。
--detect - 运行 检查解析出的变量和工具链信息,确认目标芯片和编译器。
--parse-makefile - 若需查看可用目标,运行 。
--list-targets - 使用 运行构建,按需指定
--source、--target、--clean和--extra-args。-j - 读取脚本输出的构建结果和产物扫描报告,将产物路径写回 并交给下游 skill。
Project Profile
- First read references/usage.md to confirm whether this time is for environment detection, Makefile parsing, target listing, build execution, or just artifact scanning.
- If you are not sure whether the environment is ready, first run the mode of the built-in script scripts/makefile_builder.py to confirm.
--detect - Run to check the parsed variables and toolchain information, and confirm the target chip and compiler.
--parse-makefile - To view available targets, run .
--list-targets - Use to run the build, specifying
--source,--target,--cleanand--extra-argsas needed.-j - Read the build results and artifact scan report output by the script, write the artifact path back to and pass it to downstream skills.
Project Profile
失败分流
Failure Diversion
- 当缺少 或交叉编译器时,返回
make。environment-missing - 当 Makefile 语法错误、链接失败或目标名无效时,返回 。
project-config-error - 当构建成功但未在源目录及 、
build/、output/中找到可烧录产物时,返回out/。artifact-missing - 当工作区存在多个顶层 Makefile 且意图不明确时,返回 。
ambiguous-context
- Return when
environment-missingor cross-compiler is missing.make - Return when there are Makefile syntax errors, link failures or invalid target names.
project-config-error - Return when the build is successful but no flashable artifacts are found in the source directory and
artifact-missing,build/,output/.out/ - Return when multiple top-level Makefiles exist in the workspace and the intent is unclear.
ambiguous-context
平台说明
Platform Notes
- Linux / macOS 上 通常已预装。
make - Windows 上需要 MSYS2、MinGW 或 WSL 提供 。脚本会依次尝试
make、make、gmake。mingw32-make - 输出中的构建目录应保持为绝对路径,方便下游烧录和调试 skill 直接复用。
- is usually pre-installed on Linux / macOS.
make - On Windows, is provided by MSYS2, MinGW or WSL. The script will try
make,make,gmakein sequence.mingw32-make - The build directory in the output should remain an absolute path for direct reuse by downstream flashing and debugging skills.
输出约定
Output Conventions
- 输出构建命令、构建目录、解析的工具链信息和首选产物路径。
- 用 、
artifact_path、artifact_kind和toolchain更新target_mcu。Project Profile - 成功后推荐 、
flash-openocd或flash-jlink。debug-gdb-openocd
- Output build commands, build directories, parsed toolchain information and preferred artifact paths.
- Update with
Project Profile,artifact_path,artifact_kindandtoolchain.target_mcu - Recommend ,
flash-openocdorflash-jlinkafter success.debug-gdb-openocd
交接关系
Handover Relationships
- 当下一步意图是给硬件烧录程序时,将成功构建结果交给 或
flash-openocd。flash-jlink - 当下一步需要符号信息或调试会话时,将成功构建结果交给 或
debug-gdb-openocd。debug-jlink
- When the next step is to flash the program to hardware, pass the successful build result to or
flash-openocd.flash-jlink - When symbol information or a debugging session is needed for the next step, pass the successful build result to or
debug-gdb-openocd.debug-jlink