From 3cc4c107c16c548173b98771360359b042f48173 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 3 May 2024 03:08:51 -0700 Subject: [PATCH] fixes for duo makefile and versioning --- Makefile | 17 +++++++++++++++++ VortexEngine/src/Modes/Modes.cpp | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/Makefile b/Makefile index 9477292efc..ebbd8b4f46 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,22 @@ APPEND = 0x00 # storage of modes, this does not include the eeprom. BOOTEND = 0x7e +# The branch/tag suffix for this device +BRANCH_SUFFIX=d + +# Fetch tags, determine version numbers based on the latest tag, and slice off the branch suffix +VORTEX_VERSION_MAJOR ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1 | sed 's/.$(BRANCH_SUFFIX)$$//' | cut -d. -f1) +VORTEX_VERSION_MINOR ?= $(shell git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1 | sed 's/.$(BRANCH_SUFFIX)$$//' | 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) + +# Combine into a full version number +VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER) + # compiler defines DEFINES=\ -DVORTEX_VERSION_MAJOR=$(VORTEX_VERSION_MAJOR) \ @@ -136,6 +152,7 @@ all: $(TARGET).hex $(NM) --numeric-sort --line-numbers --demangle --print-size --format=s $(TARGET).elf > $(TARGET).map chmod +x avrsize.sh ./avrsize.sh $(TARGET).elf $(BOOTEND)00 + @echo "== Success building Duo v$(VORTEX_VERSION_NUMBER) ==" $(TARGET).hex: $(TARGET).elf $(OBJCOPY) -O binary -R .eeprom $(TARGET).elf $(TARGET).bin diff --git a/VortexEngine/src/Modes/Modes.cpp b/VortexEngine/src/Modes/Modes.cpp index 42feb7e188..1f2f288429 100644 --- a/VortexEngine/src/Modes/Modes.cpp +++ b/VortexEngine/src/Modes/Modes.cpp @@ -118,6 +118,10 @@ bool Modes::saveToBuffer(ByteStream &modesBuffer) // load modes from a save buffer bool Modes::loadFromBuffer(ByteStream &modesBuffer) { + if (!modesBuffer.decompress()) { + // failed to decompress? + return false; + } if (!unserializeSaveHeader(modesBuffer)) { return false; }