Skip to content

build(build): simplify Makefile and kernel.mk test and host rules - #275

Merged
marcobuschini merged 1 commit into
mainfrom
266-issue-simplify-makefile-also-for-tests-and-host-based-tests
Dec 4, 2026
Merged

marcobuschini merged 1 commit into
mainfrom
266-issue-simplify-makefile-also-for-tests-and-host-based-tests

Conversation

@marcobuschini

Copy link
Copy Markdown
Member

Commitizen Summary

What Changed

  • Split kernel/kernel.mk into three clear groups: KERNEL_CORE_SRCS (portable subsystems shared with host tests), KERNEL_TARGET_SRCS (bare-metal / target-only sources), and auto-discovered KERNEL_SHELL_TEST_SRCS := $(sort $(wildcard kernel/shell/tests/*.cpp)).
  • Auto-discovered host test and mock sources in Makefile via HOST_TEST_CASE_SRCS := $(sort $(wildcard tests/host/*.cpp) $(wildcard tests/host/mocks/*.cpp)) and derived HOST_ONLY_TEST_SRCS, TEST_FORMAT_SRCS, and compile_commands.json --host-srcs from that single source of truth.
  • Derived HOST_KERNEL_SRCS := $(KERNEL_CORE_SRCS) directly from kernel/kernel.mk, eliminating the 41-entry duplicated list in Makefile.
  • Factored shared host C++ and linker flags into HOST_COMMON_CXXFLAGS and HOST_COMMON_LDFLAGS, and deduplicated the ASan/UBSan and gcov host compile/link rules via define_host_variant.
  • Added tests/host, tests/host/mocks, and kernel/shell/tests to compile_commands.json prerequisites so newly added auto-discovered tests refresh the compilation database automatically.
  • Updated docs/07-contributing-and-debugging.md and docs/08-testing-and-ci.md to reflect auto-discovery and KERNEL_CORE_SRCS.

Breaking Changes

None

Verification & Quality Gates

  • make clean && make -j"$(nproc)" all builds cleanly under aarch64-linux-gnu-g++ (-std=c++20 -Werror)
  • make clean-tests && make -j"$(nproc)" quality passes format-check, license-check, lint-report (clang-tidy across 140 TUs, 0 issues), and test-host
  • Identical test count and coverage vs. baseline: 85 test cases, 464,391 assertions, 13,714 lines / 10,723 executed (78%), 140 compile_commands.json entries

Checklist

- Split kernel/kernel.mk into KERNEL_CORE_SRCS (host-testable), KERNEL_TARGET_SRCS (bare-metal only), and auto-discovered KERNEL_SHELL_TEST_SRCS
- Auto-discover tests/host/*.cpp and tests/host/mocks/*.cpp in Makefile (HOST_TEST_CASE_SRCS / HOST_ONLY_TEST_SRCS) and derive TEST_FORMAT_SRCS and HOST_KERNEL_SRCS from single sources of truth
- Factor shared host flags (HOST_COMMON_CXXFLAGS, HOST_COMMON_LDFLAGS) and deduplicate ASan/UBSan and gcov host build rules via define_host_variant
- Include test directories in compile_commands.json prerequisites so newly added tests refresh the compilation database automatically
- Update build instructions in docs/07-contributing-and-debugging.md and docs/08-testing-and-ci.md

Closes #266
@marcobuschini marcobuschini linked an issue Dec 4, 2026 that may be closed by this pull request
5 tasks
@marcobuschini marcobuschini self-assigned this Dec 4, 2026
@marcobuschini
marcobuschini merged commit c6c6b19 into main Dec 4, 2026
5 checks passed
@marcobuschini
marcobuschini deleted the 266-issue-simplify-makefile-also-for-tests-and-host-based-tests branch December 4, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE] simplify Makefile also for tests and host based tests

1 participant