Build System Exists + C/C++ Collector
Enforce Build System Exists using data collected by C/C++ Collector. Automatically check devex build and ci standards on every PR.
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.
Quick Start Configuration
Add both the collector and policy to your lunar-config.yml to enable this guardrail.
# 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.
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.
dependencies
Extracts C/C++ dependencies from package managers (Conan, vcpkg) and CMakeLists.txt find_package() calls. Writes dependency data to .lang.cpp.dependencies.
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.
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.
{
"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.