gcc
Original:🇨🇳 Chinese
Translated
4 scriptsChecked / no sensitive code detected
GCC Embedded Project Build Tool (CMake + arm-none-eabi-gcc), used to scan CMake-based embedded projects, list presets, configure, compile, rebuild, clean, and analyze ELF size. It is automatically triggered when users mention GCC, arm-none-eabi, CMake embedded compilation, Ninja build, ELF size analysis, arm-gcc, cross-compilation, cmake --build, cmake --preset, and also supports explicit invocation via /gcc. Even if users just say "compile" or "check firmware size", this skill should be triggered as long as the context involves CMake-based embedded GCC projects.
1installs
Sourcezhinkgit/embeddedskills
Added on
NPX Install
npx skill4agent add zhinkgit/embeddedskills gccTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →GCC Embedded Project Build
This skill provides capabilities for embedded project discovery, preset enumeration, configuration generation, incremental compilation, full rebuild, cleaning, and ELF size analysis based on CMake + arm-none-eabi-gcc.
Scope Note: Currently only supports CMake-based GCC embedded projects, does not cover pure projects.
MakefileConfiguration
Environment-level Configuration (skill/config.json)
The in the skill directory contains environment-level configurations. Confirm the path is correct before first use:
config.jsoncmake_exejson
{
"cmake_exe": "cmake",
"toolchain_prefix": "arm-none-eabi-",
"toolchain_path": "",
"operation_mode": 1
}- : Path to the cmake executable, defaults to searching from PATH
cmake_exe - : Toolchain prefix, defaults to
toolchain_prefix, used to locate tools like sizearm-none-eabi- - : Bin directory of the toolchain, defaults to searching from PATH when empty
toolchain_path - :
operation_modeExecute directly /1Output risk summary without blocking /2Confirm before execution3
Project-level Configuration (workspace/.embeddedskills/config.json)
Shared project-level configurations are stored uniformly in of the workspace:
.embeddedskills/config.jsonjson
{
"gcc": {
"project": "",
"preset": "",
"log_dir": ".embeddedskills/build"
}
}- : Default project path (relative to workspace), will be updated automatically after successful build
project - : Default CMake preset name, will be updated automatically after successful build
preset - : Build log output directory, defaults to
log_dir.embeddedskills/build
Parameter Parsing Priority
Parameter parsing order (from highest to lowest):
- Explicit CLI parameters
- Environment-level configuration (skill/config.json)
- Project-level configuration (.embeddedskills/config.json)
- state.json (last build record)
- Search/query
Subcommands
| Subcommand | Purpose | Risk |
|---|---|---|
| Search for CMake-based embedded projects in the current directory | Low |
| List configure/build presets in CMakePresets.json | Low |
| Execute | Medium |
| Incremental compilation via | Medium |
| Clean then perform full rebuild | Medium |
| Clean build directory | High |
| Analyze ELF file size (text/data/bss and memory usage) | Low |
Execution Flow
- Read and confirm the
config.jsonpath is validcmake_exe - Default to executing when no subcommand is specified
scan - Execute first to search for projects if no project path is provided
scan - List options for users to choose when multiple projects or presets are found, never guess automatically
- Determine whether confirmation is required for based on
configure/build/rebuild/cleanoperation_mode - Automatically check if configured before , prompt to execute configure first if not configured
build - Return after successful
elf_filefor continued use bybuild/rebuildjlink/openocd - defaults to analyzing the .elf file from the most recent build
size
Script Invocation
There are three Python scripts in the skill directory, implemented with standard libraries and no additional dependencies.
gcc_project.py — Project Scanning and Preset Enumeration
bash
# Scan projects
python <skill-dir>/scripts/gcc_project.py scan --root <search directory> --json
# List presets
python <skill-dir>/scripts/gcc_project.py presets --project <project directory> --jsongcc_build.py — Configure / Compile / Rebuild / Clean
bash
python <skill-dir>/scripts/gcc_build.py <configure|build|rebuild|clean> \
--cmake <cmake path> \
--project <project root directory> \
--preset <preset name> \
--log-dir <log directory> \
--jsongcc_size.py — ELF Size Analysis
bash
# Basic analysis
python <skill-dir>/scripts/gcc_size.py analyze \
--elf <elf file path> \
--toolchain-prefix arm-none-eabi- \
--linker-script <linker script path> \
--json
# Comparative analysis
python <skill-dir>/scripts/gcc_size.py compare \
--elf <elf file 1> \
--compare <elf file 2> \
--toolchain-prefix arm-none-eabi- \
--jsonOutput Format
All scripts return in JSON format, with basic fields (ok/error), , , , and may include , , , , , .
statusactionsummarydetailscontextartifactsmetricsstatenext_actionstimingSuccess Example:
json
{
"status": "ok",
"action": "build",
"summary": "build succeeded, errors=0 warnings=2",
"details": { "project": "...", "preset": "Debug", "build_dir": "...", "elf_file": "...", "log_file": "..." },
"metrics": { "errors": 0, "warnings": 2, "flash_bytes": 99328, "ram_bytes": 46080 }
}Error Example:
json
{
"status": "error",
"action": "build",
"error": { "code": "not_configured", "message": "Build directory does not exist, please execute configure first" }
}Core Rules
- Do not modify CMakeLists.txt or any CMake configuration files
- This skill only covers CMake-based GCC projects, does not identify or build pure Makefile projects
- Never automatically guess project path or preset, must ask users when there is ambiguity
- Parameter parsing priority: Explicit CLI parameters > Environment-level configuration > Project-level configuration > > Search/query
.embeddedskills/state.json - is not implicitly executed in automatic workflows
clean - When build fails, prioritize displaying the first error and log file path
- Always include project name, preset name, build directory path in result echo; prioritize echoing when build succeeds
elf_file