Skip to content

Commit

Permalink
Update git tag/hash correctly in non-clean builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Dewb committed Jan 14, 2024
1 parent 4ee3221 commit c0828a0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ $(ragel):

firmware-build: export PATH := $(PWD)/dep/bin:$(PATH)
firmware-build: export RACK_DIR := $(realpath $(RACK_DIR))
firmware-build: firmware/*.mk firmware/**/*.c firmware/**/*.h firmware/**/**/*.rl
firmware-build:
cd firmware && $(MAKE) -f whitewhale.mk TARGET_NAME=whitewhale
cd firmware && $(MAKE) -f whitewhale.mk TARGET_NAME=whitewhale-kria
cd firmware && $(MAKE) -f meadowphysics.mk
cd firmware && $(MAKE) -f earthsea.mk
cd firmware && $(MAKE) -f ansible.mk
cd firmware && $(MAKE) -f teletype.mk TARGET_NAME=teletype4
cd firmware && $(MAKE) -f teletype.mk TARGET_NAME=teletype5
cd firmware && $(MAKE) -f ansible.mk

firmware-clean:
rm -fv res/firmware/*.dll
Expand Down
4 changes: 2 additions & 2 deletions firmware/ansible.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ SOURCES = \
$(wildcard mock_hardware/modules/ansible/*.c) \

# Add the git commit id to a file for use when printing out the version
ansible/src/gitversion.c: ansible
echo "const char *git_version = \"$(shell cut -d '-' -f 1 <<< $(shell cd ansible; git describe --tags | cut -c 1-)) $(shell cd ansible; git describe --always --dirty --exclude '*' | tr '[a-z]' '[A-Z]')\";" > $@
ansible/src/gitversion.c: $(shell find ../.git/modules/firmware/$(TARGET_NAME)/refs) ../.git/modules/firmware/$(TARGET_NAME)/packed-refs ../.git/modules/firmware/$(TARGET_NAME)/HEAD
echo "const char *git_version = \"$(GIT_VERSION)\";" > $@

include common.mk
2 changes: 2 additions & 0 deletions firmware/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ RACK_DIR ?= ../../..
TARGET_DIR := ../res/firmware/
BUILD_DIR := ../build/firmware/$(TARGET_NAME)

GIT_VERSION := $(shell cut -d '-' -f 1 <<< $(shell cd $(TARGET_NAME); git describe --tags | cut -c 1-)) $(shell cd $(TARGET_NAME); git describe --always --dirty --exclude '*' | tr '[a-z]' '[A-Z]')

FLAGS += \
-DDEBUG \
-DNULL=0 \
Expand Down
2 changes: 1 addition & 1 deletion firmware/earthsea.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ SOURCES = \
$(wildcard mock_hardware/common/*.c) \
$(wildcard mock_hardware/modules/trilogy/*.c) \

FLAGS += -DGIT_VERSION="\"$(shell cut -d '-' -f 1 <<< $(shell cd earthsea; git describe --tags | cut -c 1-)) $(shell cd earthsea; git describe --always --dirty --exclude '*' | tr '[a-z]' '[A-Z]')\""
FLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""

include common.mk
3 changes: 2 additions & 1 deletion firmware/meadowphysics.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SOURCES = \
$(wildcard mock_hardware/common/*.c) \
$(wildcard mock_hardware/modules/trilogy/*.c) \

FLAGS += -DGIT_VERSION="\"$(shell cut -d '-' -f 1 <<< $(shell cd meadowphysics; git describe --tags | cut -c 1-)) $(shell cd meadowphysics; git describe --always --dirty --exclude '*' | tr '[a-z]' '[A-Z]')\""
FLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""


include common.mk
4 changes: 2 additions & 2 deletions firmware/teletype.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $(TARGET_NAME)/src/scanner.c: $(TARGET_NAME)/src/scanner.rl
$(RAGEL) -C -G2 $(TARGET_NAME)/src/scanner.rl -o $(TARGET_NAME)/src/scanner.c

# Add the git commit id to a file for use when printing out the version
$(TARGET_NAME)/module/gitversion.c: $(TARGET_NAME)
echo "const char *git_version = \"$(shell cut -d '-' -f 1 <<< $(shell cd $(TARGET_NAME); git describe --tags | cut -c 1-)) $(shell cd $(TARGET_NAME); git describe --always --dirty --exclude '*' | tr '[a-z]' '[A-Z]')\";" > $@
$(TARGET_NAME)/module/gitversion.c: $(shell find ../.git/modules/firmware/$(TARGET_NAME)/refs) ../.git/modules/firmware/$(TARGET_NAME)/packed-refs ../.git/modules/firmware/$(TARGET_NAME)/HEAD
echo "const char *git_version = \"$(GIT_VERSION)\";" > $@

include common.mk
2 changes: 1 addition & 1 deletion firmware/whitewhale.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ SOURCES = \
$(wildcard mock_hardware/common/*.c) \
$(wildcard mock_hardware/modules/trilogy/*.c) \

FLAGS += -DGIT_VERSION="\"$(shell cut -d '-' -f 1 <<< $(shell cd $(TARGET_NAME); git describe --tags | cut -c 1-)) $(shell cd $(TARGET_NAME); git describe --always --dirty --exclude '*' | tr '[a-z]' '[A-Z]')\""
FLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""

include common.mk

0 comments on commit c0828a0

Please sign in to comment.