From: Holger Schemel Date: Sat, 19 Sep 2020 01:05:28 +0000 (+0200) Subject: added showing commit hash on version page of info screen X-Git-Tag: 4.2.0.3~18 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=438a173a61e0b6b62a5dbdda881e9c920df17165;p=rocksndiamonds.git added showing commit hash on version page of info screen --- diff --git a/.gitignore b/.gitignore index e884cfc1..f0268317 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ # ignore automatically generated files src/conftime.h +src/confhash.h src/conf_gfx.h src/conf_snd.h src/conf_mus.h diff --git a/Makefile b/Makefile index 15e686a6..3e5877f0 100644 --- a/Makefile +++ b/Makefile @@ -102,6 +102,9 @@ auto-conf: conf-time: @$(MAKE_CMD) conf-time +conf-hash: + @$(MAKE_CMD) conf-hash + run: all @$(MAKE_CMD) run diff --git a/src/Makefile b/src/Makefile index 8f18fa76..0c8a9acd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -192,6 +192,12 @@ SOURCE_DATE_EPOCH ?= $(shell test -d ../.git && test `git ls-files -m | wc -l` - # get source date string from either GNU / Linux or BSD / Mac OS X style "date" SOURCE_DATE_STRING := $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(TIMESTAMP_FORMAT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(TIMESTAMP_FORMAT)" 2>/dev/null || date -u "+$(TIMESTAMP_FORMAT)") +COMMIT_HASH_FILE = confhash.h +COMMIT_HASH_NONE = "[changed files]" + +# get last Git commit hash, if no files were changed +SOURCE_HASH_STRING ?= $(shell test -d ../.git && test `git ls-files -m | wc -l` -eq 0 && git show -s --format=%h || echo "$(COMMIT_HASH_NONE)") + LIBGAME_DIR = libgame LIBGAME = $(LIBGAME_DIR)/libgame.a @@ -224,7 +230,7 @@ GRAPHICS_DIR = ../graphics all: $(AUTOCONF) libgame_dir game_em_dir game_sp_dir game_mm_dir $(PROGNAME) graphics_dir -$(PROGNAME): $(RNDLIBS) $(TIMESTAMP_FILE) $(OBJS) $(ICON) +$(PROGNAME): $(RNDLIBS) $(TIMESTAMP_FILE) $(COMMIT_HASH_FILE) $(OBJS) $(ICON) $(CC) $(PROFILING) $(OBJS) $(ICON) $(RNDLIBS) $(LDFLAGS) -o $(PROGNAME) ifdef BUILD_DIST strip $(PROGNAME) @@ -275,9 +281,16 @@ conf-time: @echo '#define SOURCE_DATE_STRING "$(SOURCE_DATE_STRING)"' \ > $(TIMESTAMP_FILE) +conf-hash: + @echo '#define SOURCE_HASH_STRING "$(SOURCE_HASH_STRING)"' \ + > $(COMMIT_HASH_FILE) + $(TIMESTAMP_FILE): $(SRCS) $(RNDLIBS) @$(MAKE) conf-time +$(COMMIT_HASH_FILE): $(SRCS) $(RNDLIBS) + @$(MAKE) conf-hash + $(ICON): # $(CONVERT) $(ICON32X32) $(CONVERT_ICON_ARGS) $(ICONBASE).ico $(CONVERT) $(ICON_PATH)/*.png $(CONVERT_ICON_ARGS) $(ICONBASE).ico diff --git a/src/config.c b/src/config.c index 8f3bd084..d50ba684 100644 --- a/src/config.c +++ b/src/config.c @@ -13,6 +13,7 @@ #include "config.h" #include "conftime.h" +#include "confhash.h" char *getSourceDateString(void) @@ -20,6 +21,11 @@ char *getSourceDateString(void) return SOURCE_DATE_STRING; } +char *getSourceHashString(void) +{ + return SOURCE_HASH_STRING; +} + char *getProgramTitleString(void) { return program.program_title; diff --git a/src/config.h b/src/config.h index 4b1a0e71..06ae39e6 100644 --- a/src/config.h +++ b/src/config.h @@ -15,6 +15,7 @@ #include "main.h" char *getSourceDateString(void); +char *getSourceHashString(void); char *getProgramTitleString(void); char *getProgramRealVersionString(void); char *getProgramVersionString(void); diff --git a/src/screens.c b/src/screens.c index 41292512..6838dc95 100644 --- a/src/screens.c +++ b/src/screens.c @@ -3692,6 +3692,10 @@ static void DrawInfoScreen_Version(void) DrawTextF(xstart1, ystart, font_head, "Source date"); DrawTextF(xstart2, ystart, font_text, getSourceDateString()); + ystart += ystep_line; + + DrawTextF(xstart1, ystart, font_head, "Commit hash"); + DrawTextF(xstart2, ystart, font_text, getSourceHashString()); ystart += ystep_para; DrawTextF(xstart1, ystart, font_head, "Library");