From: Holger Schemel Date: Sun, 8 Jan 2017 19:44:44 +0000 (+0100) Subject: replaced compile time with source date (optionally from SOURCE_DATE_EPOCH) X-Git-Tag: 4.0.0.1~2 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=57ef2c8d4520ca5e3d537e7b2ddccef739490cb7;p=rocksndiamonds.git replaced compile time with source date (optionally from SOURCE_DATE_EPOCH) --- diff --git a/src/Makefile b/src/Makefile index dcc625cf..bb33ce8c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -183,6 +183,13 @@ CNFS = conf_gfx.h \ CNFS_CMD = ../build-scripts/create_element_defs.pl TIMESTAMP_FILE = conftime.h +TIMESTAMP_FORMAT = %Y-%m-%d %H:%M + +# use SOURCE_DATE_EPOCH, or else last Git commit date, or else current date +SOURCE_DATE_EPOCH ?= $(shell test -d ../.git && test `git ls-files -m | wc -l` -eq 0 && git show -s --format=%ct || date +%s) + +# 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)") LIBGAME_DIR = libgame LIBGAME = $(LIBGAME_DIR)/libgame.a @@ -255,10 +262,8 @@ conf_snd.h: conf_snd.c $(CNFS_CMD) conf_mus.h: conf_mus.c $(CNFS_CMD) @$(MAKE) auto-conf -# $(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM) $(GAME_SP) $(TIMESTAMP_FILE): $(SRCS) $(RNDLIBS) - @date '+"%Y-%m-%d %H:%M"' \ - | sed -e 's/^/#define COMPILE_DATE_STRING /' \ + @echo '#define SOURCE_DATE_STRING "$(SOURCE_DATE_STRING)"' \ > $(TIMESTAMP_FILE) $(ICON): diff --git a/src/config.c b/src/config.c index 0eb51d2e..608b066e 100644 --- a/src/config.c +++ b/src/config.c @@ -15,9 +15,9 @@ #include "conftime.h" -char *getCompileDateString() +char *getSourceDateString() { - return COMPILE_DATE_STRING; + return SOURCE_DATE_STRING; } char *getProgramTitleString() @@ -62,11 +62,11 @@ char *getWindowTitleString() #ifdef DEBUG window_title_string = checked_malloc(strlen(getProgramInitString()) + 20 + - strlen(getCompileDateString()) + 2 + 1); + strlen(getSourceDateString()) + 2 + 1); sprintf(window_title_string, "%s (%d %%) [%s]", getProgramInitString(), video.window_scaling_percent, - getCompileDateString()); + getSourceDateString()); #else window_title_string = checked_malloc(strlen(getProgramInitString()) + 20); @@ -78,10 +78,10 @@ char *getWindowTitleString() #ifdef DEBUG window_title_string = checked_malloc(strlen(getProgramInitString()) + 1 + - strlen(getCompileDateString()) + 2 + 1); + strlen(getSourceDateString()) + 2 + 1); sprintf(window_title_string, "%s [%s]", - getProgramInitString(), getCompileDateString()); + getProgramInitString(), getSourceDateString()); #else window_title_string = checked_malloc(strlen(getProgramInitString()) + 1); diff --git a/src/config.h b/src/config.h index f6320360..ba401a52 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ #include "main.h" -char *getCompileDateString(void); +char *getSourceDateString(void); char *getProgramTitleString(void); char *getProgramVersionString(void); char *getProgramInitString(void); diff --git a/src/screens.c b/src/screens.c index 6e26fdf5..a2f63bcd 100644 --- a/src/screens.c +++ b/src/screens.c @@ -3291,8 +3291,8 @@ void DrawInfoScreen_Version() DrawTextF(xstart2, ystart2, font_text, TARGET_STRING); ystart2 += ystep; - DrawTextF(xstart1, ystart2, font_header, "Compile time"); - DrawTextF(xstart2, ystart2, font_text, getCompileDateString()); + DrawTextF(xstart1, ystart2, font_header, "Source date"); + DrawTextF(xstart2, ystart2, font_text, getSourceDateString()); ystart2 += 3 * ystep; DrawTextF(xstart1, ystart2, font_header, "Library");