From b67b0063bc5454e1909ed96bca3314904143008b Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 21 Nov 2024 18:53:19 -0800 Subject: [PATCH] vortexcli makefile version calculation fix --- VortexEngine/VortexCLI/Makefile | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/VortexEngine/VortexCLI/Makefile b/VortexEngine/VortexCLI/Makefile index 5b4dc85bf4..b4b2f2b541 100644 --- a/VortexEngine/VortexCLI/Makefile +++ b/VortexEngine/VortexCLI/Makefile @@ -2,7 +2,7 @@ .SUFFIXES: # List all make targets which are not filenames -.PHONY: all tests clean wasm +.PHONY: all tests clean wasm compute_version # compiler tool definitions ifdef WASM @@ -21,7 +21,11 @@ CFLAGS=-O2 -g -Wall # compiler defines DEFINES=\ - -D VORTEX_LIB + -D VORTEX_LIB \ + -D VORTEX_VERSION_MAJOR=$(VORTEX_VERSION_MAJOR) \ + -D VORTEX_VERSION_MINOR=$(VORTEX_VERSION_MINOR) \ + -D VORTEX_BUILD_NUMBER=$(VORTEX_BUILD_NUMBER) \ + -D VORTEX_VERSION_NUMBER=$(VORTEX_VERSION_NUMBER) # compiler include paths INCLUDES=\ @@ -107,8 +111,8 @@ wasm: FORCE env WASM=1 $(MAKE) # target for vortex lib -vortex: $(DEPS) - $(CC) $(CFLAGS) $^ -o $@ $(LLIBS) +vortex: compute_version $(DEPS) + $(CC) $(CFLAGS) $(DEPS) -o $@ $(LLIBS) # catch-all make target to generate .o and .d files %.o: %.cpp @@ -129,6 +133,17 @@ clean: @$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) vortex.wasm *.txt FlashStorage.flash $(MAKE) -C ../VortexLib clean +# calculate the version number of the build +compute_version: + $(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list | grep --invert-match '[a-zA-Z]' | sort -V | tail -n1)) + $(eval VORTEX_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1)) + $(eval VORTEX_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f2)) + $(eval VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count $(LATEST_TAG)..HEAD)) + $(eval VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0)) + $(eval VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1)) + $(eval VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0)) + $(eval VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER)) + # Now include our target dependency files # the hyphen means ignore non-existent files -include $(DFILES)