feat: add build numbering
This commit is contained in:
@@ -225,6 +225,18 @@ override OBJ += $(addprefix obj-$(ARCH)/,$(NASMFILES:.asm=.asm.o))
|
||||
endif
|
||||
override HEADER_DEPS := $(addprefix obj-$(ARCH)/,$(CFILES:.c=.c.d) $(CXXFILES:.cpp=.cpp.d) $(OBJCFILES:.mm=.mm.d) $(ASFILES:.S=.S.d))
|
||||
|
||||
# Build number. src/Api/BuildNo.hpp holds MONTAUK_BUILD_NUMBER and is included
|
||||
# (transitively) only by Api/Syscall.cpp. We regenerate (bump) it whenever any
|
||||
# kernel object OR any userspace source changes, so the number embedded in the
|
||||
# kernel tracks real rebuilds of the kernel/userspace. Api/Syscall.cpp.o is
|
||||
# excluded from the prerequisites to avoid a dependency cycle (it depends on the
|
||||
# header), and a clean build bumps exactly once.
|
||||
override BUILDNO_HDR := src/Api/BuildNo.hpp
|
||||
override BUILDNO_OBJ := obj-$(ARCH)/Api/Syscall.cpp.o
|
||||
override PROG_SRC := $(shell find ../programs/src ../programs/include ../programs/lib \
|
||||
-type f \( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \
|
||||
-o -name '*.S' -o -name '*.asm' \) 2>/dev/null)
|
||||
|
||||
# Default target. This must come first, before header dependencies.
|
||||
.PHONY: all
|
||||
all: bin-$(ARCH)/$(OUTPUT)
|
||||
@@ -232,6 +244,15 @@ all: bin-$(ARCH)/$(OUTPUT)
|
||||
# Include header dependencies.
|
||||
-include $(HEADER_DEPS)
|
||||
|
||||
# Bump the build number when any kernel object or userspace source is newer.
|
||||
$(BUILDNO_HDR): $(filter-out $(BUILDNO_OBJ),$(OBJ)) $(PROG_SRC)
|
||||
../scripts/bump-build.sh $@
|
||||
|
||||
# Force Syscall.cpp.o to recompile (and the kernel to relink) in the same pass
|
||||
# the header is bumped, so the embedded number always matches BuildNo.hpp even
|
||||
# on a clean build (where no .d dependency exists yet).
|
||||
$(BUILDNO_OBJ): $(BUILDNO_HDR)
|
||||
|
||||
# Link rules for building the C compiler runtime.
|
||||
cc-runtime-$(ARCH)/cc-runtime.a: GNUmakefile cc-runtime/*
|
||||
rm -rf cc-runtime-$(ARCH)
|
||||
|
||||
Reference in New Issue
Block a user