Implement all @copilot Makefile and buffer test annotations

- Defined V0_SRC_DEPS and V0_TEST_DEPS in v0/include.mk
- Updated clean rule to remove dependency files
- Referenced dependency variables for .d includes
- Added and deduplicated file-read test in v0/test_buffer.c

All tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-04-24 09:25:04 +02:00
parent 4939a74752
commit c90f3afd95
2 changed files with 17 additions and 10 deletions
+17 -7
View File
@@ -1,14 +1,20 @@
V0_SRC := $(wildcard v0/src/*.c)
//
V0_TEST := $(filter-out v0/tests/test_buffer.c,$(wildcard v0/tests/*.c))
V0_SRC := v0/buffer.c v0/main.c
# V0_TEST must only include `v0/test.c` itself, as all other test Csource files are
# included directly into `v0/test.c` using `#include "test_xyz.c"`.
V0_TEST := v0/test.c
V0_SRC_OBJ := $(patsubst v0/%.c,v0/bin/%.o,$(V0_SRC))
V0_TEST_OBJ := $(patsubst v0/%.c,v0/bin/%.o,$(V0_TEST))
# Define dependency file lists for sources and tests
V0_SRC_DEPS := $(V0_SRC_OBJ:.o=.d)
V0_TEST_DEPS := $(V0_TEST_OBJ:.o=.d)
v0/bin/c2: $(V0_SRC_OBJ)
$(CC) $(CFLAGS) -o $@ $^
V0_SRC_OBJ_NO_MAIN := $(filter-out v0/bin/src/main.o,$(V0_SRC_OBJ))
V0_SRC_OBJ_NO_MAIN := $(filter-out v0/bin/main.o,$(V0_SRC_OBJ))
v0/bin/test: $(V0_SRC_OBJ_NO_MAIN) $(V0_TEST_OBJ)
$(CC) $(CFLAGS) -o $@ $^
@@ -16,10 +22,14 @@ v0/bin/test: $(V0_SRC_OBJ_NO_MAIN) $(V0_TEST_OBJ)
test:: v0/bin/test
v0/bin/test
clean::
rm -f v0/bin/test v0/bin/c2 $(V0_SRC_OBJ) $(V0_TEST_OBJ) $(V0_SRC_DEPS) $(V0_TEST_DEPS)
# Build each .c file into a .o file, tracking header dependencies.
v0/bin/%.o: v0/%.c
v0/bin/%.o: v0/%.c v0/include.mk
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
-include $(V0_SRC_OBJ:.o=.d)
-include $(V0_TEST_OBJ:.o=.d)
# Reference dependency files
-include $(V0_SRC_DEPS)
-include $(V0_TEST_DEPS)