From 31c73d2a849760bcab4891eac2a3c11f3da8da04 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 20 Nov 2024 16:43:02 -0800 Subject: [PATCH 1/2] adjusted version computation in vortexlib makefile --- VortexEngine/VortexLib/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/VortexEngine/VortexLib/Makefile b/VortexEngine/VortexLib/Makefile index 34f2b3a290..98900f08b8 100644 --- a/VortexEngine/VortexLib/Makefile +++ b/VortexEngine/VortexLib/Makefile @@ -110,7 +110,7 @@ TARGETS=vortex.a endif # Default target for 'make' command -all: compute_version $(TARGETS) +all: $(TARGETS) # unit test target tests: $(TESTS) @@ -120,11 +120,11 @@ wasm: FORCE env WASM=1 $(MAKE) # target for vortex lib -vortex.a: $(DEPS) - $(AR) $@ $^ +vortex.a: compute_version $(DEPS) + $(AR) $@ $(DEPS) -VortexLib.js: $(DEPS) - $(CC) $(LDFLAGS) $^ -o $@ $(LLIBS) +VortexLib.js: compute_version $(DEPS) + $(CC) $(LDFLAGS) $(DEPS) -o $@ $(LLIBS) # catch-all make target to generate .o and .d files %.o: %.cpp From b67b0063bc5454e1909ed96bca3314904143008b Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 21 Nov 2024 18:53:19 -0800 Subject: [PATCH 2/2] 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)