From 22c63e743a60c040d75902a0779f6d5f2862c9de Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Tue, 18 Mar 2014 22:40:30 +0100
Subject: [PATCH] Replaced date with Git hash.
---
Makefile.gh-pages | 2 +-
src/Makefile | 10 +++++++++-
src/common/version.c | 12 +++++++++---
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/Makefile.gh-pages b/Makefile.gh-pages
index f90a34c33..4c6734ca6 100644
--- a/Makefile.gh-pages
+++ b/Makefile.gh-pages
@@ -5,7 +5,7 @@
GH_PAGES = ../gh-pages
all:
- date +%F | zip -z cc65
+ echo $(TRAVIS_COMMIT) | zip -z cc65
ifdef GH_TOKEN
git clone --branch=gh-pages https://$(GH_TOKEN)@github.com/cc65/cc65.git $(GH_PAGES)
cd $(GH_PAGES) && git config user.name "Oliver Schmidt"
diff --git a/src/Makefile b/src/Makefile
index 17754190c..2c2267ae7 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -39,9 +39,17 @@ ifdef USER_CFLAGS
$(info USER_CFLAGS: $(USER_CFLAGS))
endif
+ifndef GIT_SHA
+ GIT_SHA := $(if $(wildcard ../.git),$(shell git rev-parse --short HEAD))
+ ifneq ($(words $(GIT_SHA)),1)
+ GIT_SHA := N/A
+ endif
+endif
+$(info GIT_SHA: $(GIT_SHA))
+
CFLAGS += -MMD -MP -O -I common \
-Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \
- -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \
+ -DGIT_SHA=$(GIT_SHA) -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \
-DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG)
LDLIBS += -lm
diff --git a/src/common/version.c b/src/common/version.c
index 51921d190..d2fcf4f40 100644
--- a/src/common/version.c
+++ b/src/common/version.c
@@ -33,8 +33,10 @@
-#include "version.h"
+/* common */
#include "xsprintf.h"
+#include "searchpath.h"
+#include "version.h"
@@ -58,8 +60,12 @@
const char* GetVersionAsString (void)
/* Returns the version number as a string in a static buffer */
{
- static char Buf[40];
- xsnprintf (Buf, sizeof (Buf), "%u.%u - %s", VER_MAJOR, VER_MINOR, __DATE__);
+ static char Buf[60];
+#if defined(GIT_SHA)
+ xsnprintf (Buf, sizeof (Buf), "%u.%u - Git %s", VER_MAJOR, VER_MINOR, STRINGIZE (GIT_SHA));
+#else
+ xsnprintf (Buf, sizeof (Buf), "%u.%u", VER_MAJOR, VER_MINOR);
+#endif
return Buf;
}
--
2.39.5