Repository navigation
Done
Description
Problem
Makefile and kernel/kernel.mk currently maintain large, manually synchronized file lists and duplicated build rules for both kernel shell tests and host (snitch) unit tests:
- Manual
HOST_ONLY_TEST_SRCSenumeration (Makefilelines 70–104)- Every
tests/host/*.cppfile must be listed by hand. Omitting a file silently excludes it fromtest-hostandlint-report(e.g.tests/host/virtio_blk_test.cppwas previously left out ofHOST_ONLY_TEST_SRCSeven thoughTEST_FORMAT_SRCSdiscovered it viafind).
- Every
- Duplicated
HOST_KERNEL_SRCSlist (Makefilelines 106–147 vs.kernel/kernel.mk)HOST_KERNEL_SRCSmanually duplicates 40+ kernel.cpppaths already listed inkernel/kernel.mk, creating drift whenever kernel modules are added or moved.
- Manual
kernel/shell/tests/*.cpplist (kernel/kernel.mklines 18–64)- 47 shell test source files are listed explicitly instead of being discovered or grouped cleanly.
- Duplicated host compiler flags & pattern rules (
Makefilelines 58–68, 199–215)HOST_CXXFLAGSandHOST_COV_CXXFLAGSrepeat the same C++20, warning,-DHOST_TEST, and-MMD -MPflags.
Proposed Simplification
- Auto-discover host tests in
Makefile(or a dedicatedtests/host/host.mk):(keepingHOST_ONLY_TEST_SRCS := $(sort $(wildcard tests/host/*.cpp) $(wildcard tests/host/mocks/*.cpp)) $(DRIVER_SRCS)
TEST_FORMAT_SRCSandlint-report's--host-srcsderived from the exact same source of truth). - Derive
HOST_KERNEL_SRCSfromkernel/kernel.mkinstead of duplicating it inMakefile— e.g. splitkernel/kernel.mkinto host-testableKERNEL_CORE_SRCSvs. bare-metal-onlyKERNEL_TARGET_SRCS(or compute$(filter-out ..., $(SRCS_CXX))), soHOST_KERNEL_SRCSstays automatically in sync. - Auto-discover shell tests in
kernel/kernel.mk:SRCS_CXX += $(sort $(wildcard kernel/shell/tests/*.cpp))
- Factor shared host flags (
HOST_COMMON_CXXFLAGS) betweenHOST_CXXFLAGSandHOST_COV_CXXFLAGS.
Acceptance Criteria
-
HOST_ONLY_TEST_SRCSautomatically discovers alltests/host/*.cppandtests/host/mocks/*.cppwithout manual per-file edits. -
HOST_KERNEL_SRCSis derived from a single source of truth shared withkernel/kernel.mk(no duplicated file list). -
kernel/shell/tests/*.cppare discovered without manual per-file enumeration inkernel/kernel.mk. - Shared host C++ flags are factored into a common variable.
-
make clean && make -j"$(nproc)" all && make clean-tests && make -j"$(nproc)" qualitypasses with identical test count, coverage, formatting, and lint results.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
build(build): simplify Makefile and kernel.mk test and host rules