diff --git a/.github/workflows/duo_build.yml b/.github/workflows/duo_build.yml index 3e10dd8f7e..4cf28a6303 100644 --- a/.github/workflows/duo_build.yml +++ b/.github/workflows/duo_build.yml @@ -37,6 +37,8 @@ jobs: VERSION_NUMBER=$(echo $LATEST_TAG | sed "s/${BRANCH_SUFFIX}//g") VERSION_MAJOR=$(echo $VERSION_NUMBER | cut -d. -f1) VERSION_MINOR=$(echo $VERSION_NUMBER | cut -d. -f2) + echo "Revisions:" + git rev-list $LATEST_TAG..HEAD BUILD_NUMBER=$(git rev-list --count $LATEST_TAG..HEAD) fi FULL_VERSION="$VERSION_MAJOR.$VERSION_MINOR.$BUILD_NUMBER" diff --git a/Makefile b/Makefile index 9a6ed64186..9217448735 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +.PHONY: all clean install serial upload compute_version + ifeq ($(OS),Windows_NT) # Windows BINDIR="C:/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/" AVRDUDEDIR="$(shell echo "$$LOCALAPPDATA")/Arduino15/packages/DxCore/tools/avrdude/6.3.0-arduino17or18/bin" @@ -67,19 +69,6 @@ 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 | 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) \ @@ -147,7 +136,7 @@ DFILES = $(SRCS:.cpp=.d) # Target name TARGET = vortex -all: $(TARGET).hex +all: compute_version $(TARGET).hex $(OBJDUMP) --disassemble --source --line-numbers --demangle --section=.text $(TARGET).elf > $(TARGET).lst $(NM) --numeric-sort --line-numbers --demangle --print-size --format=s $(TARGET).elf > $(TARGET).map chmod +x avrsize.sh @@ -168,7 +157,7 @@ $(TARGET).elf: $(OBJS) %.o: %.cpp $(CC) $(CFLAGS) -c $< -o $@ -upload: $(TARGET).hex +upload: all $(AVRDUDE) $(AVRDUDE_FLAGS) \ -Ufuse0:w:$(WDTCFG):m \ -Ufuse1:w:$(BODCFG):m \ @@ -181,7 +170,7 @@ upload: $(TARGET).hex -Uflash:w:$(TARGET).hex:i # upload via SerialUPDI -serial: $(TARGET).hex +serial: all $(PYTHON) -u $(PYPROG) -t uart -u $(SERIAL_PORT) -b 921600 -d $(AVRDUDE_CHIP) \ --fuses 0:$(WDTCFG) 1:$(BODCFG) 2:$(OSCCFG) 4:$(TCD0CFG) 5:$(SYSCFG0) 6:$(SYSCFG1) 7:$(APPEND) 8:$(BOOTEND) -f $< -a write -v @@ -208,5 +197,15 @@ endif clean: rm -f $(OBJS) $(TARGET).elf $(TARGET).hex $(DFILES) +compute_version: + $(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1)) + $(eval VORTEX_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1)) + $(eval VORTEX_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | sed 's/$(BRANCH_SUFFIX)$$//' | 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)) + # include dependency files to ensure partial rebuilds work correctly -include $(DFILES) diff --git a/VortexEngine/VortexLib/Makefile b/VortexEngine/VortexLib/Makefile index 80d0337572..4528a64b4f 100644 --- a/VortexEngine/VortexLib/Makefile +++ b/VortexEngine/VortexLib/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 @@ -24,17 +24,8 @@ 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) +# The branch/tag suffix for this device +BRANCH_SUFFIX=d # compiler defines DEFINES=\ @@ -122,7 +113,7 @@ TARGETS=vortex.a endif # Default target for 'make' command -all: $(TARGETS) +all: compute_version $(TARGETS) # unit test target tests: $(TESTS) @@ -156,6 +147,16 @@ FORCE: clean: @$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) VortexLib.js vortex.wasm +compute_version: + $(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1)) + $(eval VORTEX_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1)) + $(eval VORTEX_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | sed 's/$(BRANCH_SUFFIX)$$//' | 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)