From f64475a515ecffe9f173c954b855ed9faeeccad8 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Tue, 12 Feb 2019 00:49:29 -0800 Subject: [PATCH] First stab at using export-subst in .gitattributes. --- .gitignore | 2 +- Makefile | 20 +++++++++++--------- src/common/git_hash.h | 5 +++++ 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 src/common/git_hash.h diff --git a/.gitignore b/.gitignore index 77bf838..57b2b4d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ frotz-* *.tar *.gz src/common/version.c -src/common/git_hash.h +#src/common/git_hash.h src/common/defs.h src/curses/ux_defines.h *.z? diff --git a/Makefile b/Makefile index 172331a..0a5b777 100644 --- a/Makefile +++ b/Makefile @@ -121,13 +121,9 @@ ifneq ($(and $(wildcard $(GIT_DIR)),$(shell which git)),) GIT_HASH = $(shell git rev-parse HEAD) GIT_HASH_SHORT = $(shell git rev-parse --short HEAD) GIT_TAG = $(shell git describe --abbrev=0 --tags) -else - GIT_BRANCH = none - GIT_HASH = none - GIT_HASH_SHORT = none - GIT_TAG = none + GIT_DATE = $(shell git show -s --format=%ci) endif -BUILD_DATE_TIME = $(shell date +%Y%m%d.%k%M%S | sed s/\ //g) +BUILD_DATE_TIME = $(shell date --rfc-3339 seconds) export CFLAGS @@ -268,17 +264,23 @@ endif ifdef COLOR @echo "#define COLOR_SUPPORT" >> $@ endif - @echo "#endif /* CURSES_DEFINES_H */" >> $@ hash: $(HASH) -$(HASH): +ifneq ($(and $(wildcard $(GIT_DIR)),$(shell which git)),) + @echo "** Generating $@" + + + + +$(HASH_OLD): @echo "** Generating $@" @echo "#define GIT_BRANCH \"$(GIT_BRANCH)\"" > $@ @echo "#define GIT_HASH \"$(GIT_HASH)\"" >> $@ @echo "#define GIT_HASH_SHORT \"$(GIT_HASH_SHORT)\"" >> $@ @echo "#define GIT_TAG \"$(GIT_TAG)\"" >> $@ + @echo "#define GIT_DATE \"$(GIT_DATE)\"" >> $@ # Administrative stuff @@ -336,7 +338,7 @@ clean: $(SUB_CLEAN) $(SRCDIR)/*.a \ $(COMMON_DEFINES) \ $(COMMON_STRINGS) \ - $(HASH) \ +# $(HASH) \ $(CURSES_DEFINES) \ $(NAME)*.tar.gz diff --git a/src/common/git_hash.h b/src/common/git_hash.h new file mode 100644 index 0000000..1fe2b90 --- /dev/null +++ b/src/common/git_hash.h @@ -0,0 +1,5 @@ +#define GIT_BRANCH "$Format: %D$" +#define GIT_TAG "$Format: %D$" +#define GIT_HASH "$Format: %H$" +#define GIT_HASH_SHORT "$Format: $h$" +#define GIT_DATE "$Format: $ci$" -- 2.34.1