make: improve the Git commit approximation scheme

Retrieve commit from branch reference when not in detached HEAD mode. A
full rebuild is still needed after changing branch, but not at each
commit.
This commit is contained in:
Lephe 2020-06-14 08:30:09 +02:00
parent 41294ec0a4
commit b2172dd88e
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 8 additions and 1 deletions

View File

@ -33,6 +33,13 @@ sflags := $(CONFIG.MACROS)
dflags = -MMD -MT $@ -MF $(@:.o=.d) -MP
arflags :=
# Git file with current hash
ifeq "$(shell git branch --show-current)" ""
gitfile := ../.git/HEAD
else
gitfile := ../.git/refs/heads/$(shell git branch --show-current)
endif
#
# File listings
@ -118,7 +125,7 @@ $(call src2obj,../src/font8x9.png): ../src/font8x9.png
# Version symbol. ld generates a .stack section for unknown reasons; I remove
# it in the linker script.
version.o: ../.git/HEAD
version.o: $(gitfile)
@ mkdir -p $(dir $@)
@ echo "_GINT_VERSION = $(version_hash);" > $@.txt
$(call cmd_b,ld,$@) $(ld) -r -R $@.txt -o $@