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
Added on

NPX Install

npx skill4agent add zhinkgit/embeddedskills gcc

Tags

Translated version includes tags in frontmatter

SKILL.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
Makefile
projects.

Configuration

Environment-level Configuration (skill/config.json)

The
config.json
in the skill directory contains environment-level configurations. Confirm the
cmake_exe
path is correct before first use:
json
{
  "cmake_exe": "cmake",
  "toolchain_prefix": "arm-none-eabi-",
  "toolchain_path": "",
  "operation_mode": 1
}
  • cmake_exe
    : Path to the cmake executable, defaults to searching from PATH
  • toolchain_prefix
    : Toolchain prefix, defaults to
    arm-none-eabi-
    , used to locate tools like size
  • toolchain_path
    : Bin directory of the toolchain, defaults to searching from PATH when empty
  • operation_mode
    :
    1
    Execute directly /
    2
    Output risk summary without blocking /
    3
    Confirm before execution

Project-level Configuration (workspace/.embeddedskills/config.json)

Shared project-level configurations are stored uniformly in
.embeddedskills/config.json
of the workspace:
json
{
  "gcc": {
    "project": "",
    "preset": "",
    "log_dir": ".embeddedskills/build"
  }
}
  • project
    : Default project path (relative to workspace), will be updated automatically after successful build
  • preset
    : Default CMake preset name, will be updated automatically after successful build
  • log_dir
    : Build log output directory, defaults to
    .embeddedskills/build

Parameter Parsing Priority

Parameter parsing order (from highest to lowest):
  1. Explicit CLI parameters
  2. Environment-level configuration (skill/config.json)
  3. Project-level configuration (.embeddedskills/config.json)
  4. state.json (last build record)
  5. Search/query

Subcommands

SubcommandPurposeRisk
scan
Search for CMake-based embedded projects in the current directoryLow
presets
List configure/build presets in CMakePresets.jsonLow
configure
Execute
cmake --preset
to generate build system
Medium
build
Incremental compilation via
cmake --build
Medium
rebuild
Clean then perform full rebuildMedium
clean
Clean build directoryHigh
size
Analyze ELF file size (text/data/bss and memory usage)Low

Execution Flow

  1. Read
    config.json
    and confirm the
    cmake_exe
    path is valid
  2. Default to executing
    scan
    when no subcommand is specified
  3. Execute
    scan
    first to search for projects if no project path is provided
  4. List options for users to choose when multiple projects or presets are found, never guess automatically
  5. Determine whether confirmation is required for
    configure/build/rebuild/clean
    based on
    operation_mode
  6. Automatically check if configured before
    build
    , prompt to execute configure first if not configured
  7. Return
    elf_file
    after successful
    build/rebuild
    for continued use by
    jlink/openocd
  8. size
    defaults to analyzing the .elf file from the most recent build

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> --json

gcc_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> \
  --json

gcc_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- \
  --json

Output Format

All scripts return in JSON format, with basic fields
status
(ok/error),
action
,
summary
,
details
, and may include
context
,
artifacts
,
metrics
,
state
,
next_actions
,
timing
.
Success 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 >
    .embeddedskills/state.json
    > Search/query
  • clean
    is not implicitly executed in automatic workflows
  • 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
    elf_file
    when build succeeds