Hamburger Cross Icon
Build System Exists
+
C/C++ Collector

Build System Exists + C/C++ Collector

Guardrail Collector Beta Devex Build And Ci

Enforce Build System Exists using data collected by C/C++ Collector. Automatically check devex build and ci standards on every PR.

Guardrail: Ensures at least one build system (CMake, Make, Meson, Autotools, Bazel) is detected. Unlike Go or Rust where the toolchain is the build system, C/C++ projects require an explicit build system to be compilable.
Data Source: Analyze C/C++ projects to collect build system info (CMake, Make, Meson, Autotools), dependency graphs, cppcheck linting, and CI compiler commands. Enforce C/C++ engineering standards.

How C/C++ Collector Powers This Guardrail

The C/C++ Collector gathers metadata from your languages, build systems. This data flows into Lunar's Component JSON, where the Build System Exists guardrail evaluates it against your standards.

When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.

1
C/C++ Collector Gathers Data Collector
Extracts metadata from code, configs, and tool outputs
2
{ } Component JSON
Data centralized in structured format for evaluation
3
Build System Exists Checks Guardrail
Pass/fail result with actionable feedback in PRs

Quick Start Configuration

Add both the collector and policy to your lunar-config.yml to enable this guardrail.

📄 lunar-config.yml
# Step 1: Enable the C/C++ Collector
collectors:
  - uses: github://earthly/lunar-lib/collectors/cpp@v1.0.5
    # with: ...

# Step 2: Enable the C/C++ Project Guardrails
policies:
  - uses: github://earthly/lunar-lib/policies/cpp@v1.0.5
    include: [build-system-exists]
    # with: ...

What C/C++ Collector Collects

This collector gathers the following data that the Build System Exists guardrail evaluates.

Collector code

project

Detects C/C++ project structure including build systems (CMake, Make, Meson, Autotools, Bazel), source file counts, C++ standard version, and package manager configuration (Conan, vcpkg). Writes project metadata to .lang.cpp.

Collector code

dependencies

Extracts C/C++ dependencies from package managers (Conan, vcpkg) and CMakeLists.txt find_package() calls. Writes dependency data to .lang.cpp.dependencies.

Collector code

cppcheck

Runs cppcheck static analysis on C/C++ source files. Collects lint warnings with file, line, severity, and message. Writes normalized warnings to .lang.cpp.lint and raw output to .lang.cpp.native.cppcheck.

Collector ci-before-command

cicd

Records C/C++ compiler commands (gcc, g++, clang, clang++) executed in CI pipelines along with compiler version. Writes command strings and version info to .lang.cpp.cicd for audit trails and build reproducibility.

Example Data Flow

Here's an example of the data that C/C++ Collector writes to the Component JSON, which Build System Exists then evaluates.

{ } component.json From C/C++ Collector
{
  "lang": {
    "cpp": {
      "build_systems": ["cmake", "make"],
      "cmake_exists": true,
      "makefile_exists": true,
      "conanfile_exists": false,
      "vcpkg_json_exists": false,
      "meson_build_exists": false,
      "cpp_standard": "17",
      "source_files": {
        "c": 5,
        "cpp": 23,
        "headers": 18
      },
      "source": { "tool": "cpp", "integration": "code" },
      "dependencies": {
        "direct": [
          { "name": "boost/1.82.0", "version": "1.82.0", "manager": "conan" }
        ],
        "cmake_packages": ["Boost", "OpenSSL", "Threads"],
        "source": { "tool": "cpp", "integration": "code" }
      },
      "lint": {
        "warnings": [
          {
            "file": "src/main.cpp",
            "line": 42,
            "severity": "warning",
            "message": "Variable 'x' is not initialized",
            "id": "uninitvar"
          }
        ],
        "tool": "cppcheck",
        "source": { "tool": "cppcheck", "integration": "code" }
      },
      "native": {
        "cppcheck": {
          "passed": true,
          "exit_code": 0,
          "error_count": 0,
          "warning_count": 1,
          "source": { "tool": "cppcheck", "integration": "code" }
        }
      },
      "cicd": {
        "cmds": [
          { "cmd": "g++ -std=c++17 -O2 -o main main.cpp", "version": "12.2.0" },
          { "cmd": "cmake --build . --config Release", "version": "3.27.0" }
        ],
        "source": { "tool": "cpp", "integration": "ci" }
      }
    }
  }
}

Configuration Options

C/C++ Project Guardrails Inputs

Input Required Default Description
min_cpp_standard Optional 17 Minimum required C++ standard (e.g., "17", "20", "23")
max_cppcheck_warnings Optional 0 Maximum allowed cppcheck warnings (0 = must be clean)
min_compiler_version Optional 12.0.0 Minimum required compiler version for CI/CD (e.g., "12.0.0" for gcc, "15.0.0" for clang)
min_cmake_version Optional 3.20.0 Minimum required CMake version for CI/CD (e.g., "3.20.0")

Ready to Automate Your Standards?

See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.

Works with any process
check AI agent rules & prompt files
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Paste your AGENTS.md or manual process doc and get guardrails in minutes
Book a Demo