Skip to content

Commit

Permalink
Updated makefile for gloves version fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Nov 19, 2024
1 parent 0c80f6f commit 7b5850f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
28 changes: 13 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all install build upload clean
.PHONY: all install build upload clean compute_version

ARDUINO_CLI = ./bin/arduino-cli --verbose
BOARD = adafruit:samd:adafruit_trinket_m0
Expand All @@ -10,19 +10,6 @@ CONFIG_FILE = $(HOME)/.arduino15/arduino-cli.yaml
# The branch/tag suffix for this device
BRANCH_SUFFIX=g

# 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)

DEFINES=\
-D VORTEX_VERSION_MAJOR=$(VORTEX_VERSION_MAJOR) \
-D VORTEX_VERSION_MINOR=$(VORTEX_VERSION_MINOR) \
Expand Down Expand Up @@ -54,7 +41,7 @@ install:
chmod +x rewrite_trinket_source.sh
./rewrite_trinket_source.sh

build:
build: compute_version
$(ARDUINO_CLI) compile --fqbn $(BOARD) $(PROJECT_NAME) \
--config-file $(CONFIG_FILE) \
--build-path $(BUILD_PATH) \
Expand All @@ -71,3 +58,14 @@ core-list:

clean:
rm -rf $(BUILD_PATH)

# 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 "*$(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))
7 changes: 5 additions & 2 deletions VortexEngine/VortexLib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ ifndef WASM
CFLAGS += -g
endif

# The branch/tag suffix for this device
BRANCH_SUFFIX=g

# compiler defines
DEFINES=\
-D VORTEX_LIB \
Expand Down Expand Up @@ -146,9 +149,9 @@ 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 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) | cut -d. -f2))
$(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))
Expand Down

0 comments on commit 7b5850f

Please sign in to comment.