diff --git a/VortexEngine/VortexLib/Makefile b/VortexEngine/VortexLib/Makefile index c136b665bd..80d0337572 100644 --- a/VortexEngine/VortexLib/Makefile +++ b/VortexEngine/VortexLib/Makefile @@ -24,6 +24,18 @@ ifndef WASM CFLAGS += -g endif +# Determine the current version based on Git tags +VORTEX_VERSION_MAJOR ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list | grep -E "^[[:digit:]]+\.[[:digit:]]+\$$" | sort -V | tail -n1 | cut -d. -f1) +VORTEX_VERSION_MINOR ?= $(shell git tag --list | grep -E "^[[:digit:]]+\.[[:digit:]]+\$$" | sort -V | tail -n1 | cut -d. -f2) +VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count HEAD) + +# If no tags are found, default to 0.1.0 +VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0) +VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1) +VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0) + +VORTEX_VERSION_NUMBER ?= $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER) + # compiler defines DEFINES=\ -D VORTEX_LIB \ diff --git a/VortexEngine/src/VortexConfig.h b/VortexEngine/src/VortexConfig.h index 360c5582d6..37f0a73f5e 100644 --- a/VortexEngine/src/VortexConfig.h +++ b/VortexEngine/src/VortexConfig.h @@ -26,7 +26,7 @@ #define VORTEX_BUILD_NUMBER 0 #endif -// produces a number like 1.0 +// produces a number like 1.0.0 #ifndef VORTEX_VERSION_NUMBER #define VORTEX_VERSION_NUMBER VORTEX_VERSION_MAJOR.VORTEX_VERSION_MINOR.VORTEX_BUILD_NUMBER #endif