Repository navigation
feat: support c, c++ and assembly as one cmake language - #323
Merged
Merged
Conversation
added 3 commits
November 18, 2026 13:17
Microcontroller firmware mixes a startup file in assembly, a HAL in C and application code in C or C++ inside one build target, so the three are one detected language, cpp, present when the root holds a CMakeLists.txt. Three detectors over one build file would give three adapter columns that could never differ, and CodeQL already counts C and C++ as the single language c-cpp. CMake over GNU Make because the checks need what only CMake reports: a compilation database for clang-tidy, a test registry for ctest, and, for the run and package adapters still to come, the File API's list of executables. Make would push all three onto a list each repository keeps by hand. clang-tidy and clang-format read the compilation database intersected with the repository's own C and C++ files. That drops assembly, which neither tool can parse, along with vendored trees and sources fetched or generated into build/. The root build/ is pruned from every search, since FetchContent clones dependency trees into it, and scripts/clean removes it by path. ctest reads only the top-level CTestTestfile.cmake, which CMake writes only when the root calls enable_testing(). A unit's own call leaves every add_test() below it skipped behind a passing "No tests were found", so the test adapter refuses a nested test file that has no top-level one. run and package stay absent, so scripts/run and scripts/package report unavailable for a C or C++ unit. A firmware unit's ship targets wait until one exists. ADR 0011 records the decision. Generated-By: claude-opus-5-5
Correctness review of #323 found three ways the cpp adapters misreport: - clang-tidy matched compile_commands.json entries against `pwd -P`, but CMake writes the logical path it ran from, so a checkout reached through a symlink linted no units and passed. Entries are now compared relative to either path. - the enable_testing guard fired on any nested CTestTestfile.cmake, including a dependency's under build/_deps that calls include(CTest), failing a project with no tests. It now refuses only a nested file that declares add_test(), outside _deps/ and vendor/. - the orphan search reported every nested CMakeLists.txt in a repository with no root one, including an Android NDK library under src/ or a scikit-build or cmake-js build beside its own manifest, so existing Kotlin, Python and Node repositories would fail detection. Those are now left to the language that owns them. The fourth finding, gcc-only flags reaching clang-tidy as unknown arguments, is recorded as a consequence in ADR 0011 rather than worked around, since choosing the lint compiler is the repository's call. Also applies the standards review's wording fixes: the language counts in scripts/package, dependabot-entries-test and the structure doc, and the Dependabot exception in the adding-a-language rule. Generated-By: claude-opus-5-5
The narrowed enable_testing guard matched only a line starting add_test(, but gtest_discover_tests and catch_discover_tests write an include() of the discovered list in its place, and multi-config generators indent add_test() under if(CTEST_CONFIGURATION_TYPE ...). Either let a unit's tests be skipped with "No tests were found" again. The guard now matches an optionally indented add_test( or include(; a subdirs()-only file still declares nothing. Generated-By: claude-opus-5-5
Owner
Author
|
Code review: standard scan, clean. Axes: Standards+Spec, Correctness/Logic Reviewed-Head: 9ab1e47 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Operator request in session: add C, C++ and assembly as template languages, built by CMake, with firmware ship targets deferred until a firmware unit exists.
Before this change, a repository holding C, C++ or assembly got no lint, format, build, test or CodeQL coverage, and the gate reported nothing for it. After it, a root
CMakeLists.txtmakescpppresent:build/and ctest runs the tests.c-cppwithbuild-mode: none.All of this lands in both the root and the payload.
Read first
scripts/libs/detect.sh:250—cpp_sources,cmake_configure,_cmake_translation_units(logical-or-physical path match) and thecppadapters, through the_capability_test_cppenable_testing guard;_cmake_owned_elsewhereat:380narrows the orphan searchdocs/adrs/0011-support-c-cpp-and-assembly-as-one-cmake-language.md— the decision and the three probed behaviours that shaped the adaptersscripts/tests/capabilities-test— the probe table's newcppcolumn, plus eight new fixtures: detection, the orphanCMakeLists.txt, aCMakeLists.txtowned by another build, the lint unit set, lint through a symlinked checkout, the enable_testing refusal (indentedadd_test()and discovered-testinclude()), and a dependency's own testsapps/github-repository-template/src/base-repo/scripts/and.github/file is a byte copy of its root counterpart (scripts/payload-paritypasses);docs/adrs/index.mdis generatedDecisions
cpplanguage over three separate languages, because one build file compiles all three and CodeQL already treats C and C++ as one language.cpp_sources, not the whole DB, because clang-tidy fails on.Sand the DB also lists vendored andbuild/sources.lint-fixrunsclang-tidy --fixwithout--warnings-as-errors, because with that flag it exits 1 even after it has applied the fixes.CTestTestfile.cmakedeclaring a test (anadd_test(), indented under a multi-config generator, or theinclude()gtest and Catch2 discovery writes) with no top-level one is refused, because ctest would skip those tests silently. Files underbuild/_deps/andvendor/are a dependency's and do not count.CMakeLists.txtbelow asrc/or beside another language's manifest is not an orphan: it is that language's native build (Android NDK, scikit-build, cmake-js), and flagging it would fail existing Kotlin, Python and Node repositories.runandpackageare left absent, not stubbed, soscripts/runandscripts/packagereportunavailablefor a C/C++ unit (the same gap Swift has forrun).CMakeLists.txtgets no Dependabot mapping, because Dependabot has no CMake ecosystem.cpphas nopackageadapter.apps/repo-builder/src/scripts/retrofit.py'sMANIFESTSdoes not gainCMakeLists.txt, because C/C++ tools are found onPATHand never declared in a manifest.Out of scope
run/packageadapter forcpp: deferred until a firmware unit exists (ADR 0011).Verified
scripts/check→EXIT=0, every rowpassornot-applicablescripts/checkat9ab1e47→EXIT=0scripts/tests/capabilities-test→79 passed, 0 failed. Each new fixture fails under a mutation of its fix: dropping the logical-path strip, the_deps/vendorprune, the declared-test grep, itsincludealternative, its leading-space allowance, or the_cmake_owned_elsewherecall each gives one failure. The enable_testing fixture fails when the guard'sreturn 1is replaced withtrue, and the lint fixture fails when the duplicate-unitunsetis removedscripts/tests/clean-test→3 passed;scripts/tests/structure-test→84 passedscripts/payload-parity→the root and payload .github/ and scripts/ trees agreelanguage_capabilities run <check>on host CMake 3.31.6 and clang-format/clang-tidy 19.1.7: toolchain, lint, format-check, build, test, lint-fix and format-writepass; typecheck, audit and integrationnot-applicable;runandpackageunavailable;codeql-matrixemits{"language":"c-cpp","build-mode":"none","runner":"ubuntu-latest"}Not verified
cppis detected, and this repository has noCMakeLists.txt, so CI here never runs it._depsand orphan-ownership fixes are covered by stubbed fixtures only, not a real symlinked checkout, FetchContent build, or NDK project.FetchContent, and the CodeQL analysis job itself were not run.Merge danger
Door: two-way: a revert restores everything; no data, schema or published interface changes.
Blast radius:
detect.sh. Its searches now prune the rootbuild/for every language, so nothing under it is linted, formatted or collected.scripts/cleanalready removed thatbuild/through its name search, and now removes it by path.scripts/structure's root allowlist gains three files.language_capabilities probeoutput gains sevencpprows, and thedetectGitHub output gainscpp=./repo-builderlifecycle.mdDependabot and first-manifest guidance.