From d3377e776c72f5d5860fa804728b959e15ab2a8a Mon Sep 17 00:00:00 2001 From: George Smart Date: Thu, 9 Mar 2017 20:55:41 +0000 Subject: [PATCH] Added Git Version number (*NIX only) --- .gitignore | 1 + MMDVMHost.cpp | 2 ++ Makefile | 13 ++++++++++--- Makefile.Pi | 13 ++++++++++--- Makefile.Pi.Adafruit | 13 ++++++++++--- Makefile.Pi.HD44780 | 13 ++++++++++--- Makefile.Pi.OLED | 13 ++++++++++--- Makefile.Pi.PCF8574 | 12 ++++++++++-- Makefile.Solaris | 13 ++++++++++--- 9 files changed, 73 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index f1260a1..158435f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ MMDVMHost *.VC.db .vs *.ambe +gitversion.h diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index cea5c9b..a875ec4 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -33,6 +33,7 @@ #include "LCDproc.h" #include "Thread.h" #include "Log.h" +#include "gitversion.h" #if defined(HD44780) #include "HD44780.h" @@ -235,6 +236,7 @@ int CMMDVMHost::run() LogInfo(HEADER4); LogMessage("MMDVMHost-%s is starting", VERSION); + LogMessage("Built %s %s (GitID #%.7s)", __TIME__, __DATE__, gitversion); readParams(); diff --git a/Makefile b/Makefile index f180e2d..b1f1050 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,19 @@ OBJECTS = \ all: MMDVMHost -MMDVMHost: $(OBJECTS) +MMDVMHost: gitversion.h $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< clean: - $(RM) MMDVMHost *.o *.d *.bak *~ - + $(RM) MMDVMHost *.o *.d *.bak *~ gitversion.h + +# Export the current git version if the index file exists, else 000... +gitversion.h: +ifneq ("$(wildcard .git/index)","") + echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ +else + echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ +endif diff --git a/Makefile.Pi b/Makefile.Pi index 0734d47..f683ec6 100644 --- a/Makefile.Pi +++ b/Makefile.Pi @@ -15,12 +15,19 @@ OBJECTS = \ all: MMDVMHost -MMDVMHost: $(OBJECTS) +MMDVMHost: gitversion.h $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< clean: - $(RM) MMDVMHost *.o *.d *.bak *~ - + $(RM) MMDVMHost *.o *.d *.bak *~ gitversion.h + +# Export the current git version if the index file exists, else 000... +gitversion.h: +ifneq ("$(wildcard .git/index)","") + echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ +else + echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ +endif diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit index bbe5dfe..16ecc2f 100644 --- a/Makefile.Pi.Adafruit +++ b/Makefile.Pi.Adafruit @@ -15,12 +15,19 @@ OBJECTS = \ all: MMDVMHost -MMDVMHost: $(OBJECTS) +MMDVMHost: gitversion.h $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< clean: - $(RM) MMDVMHost *.o *.d *.bak *~ - + $(RM) MMDVMHost *.o *.d *.bak *~ gitversion.h + +# Export the current git version if the index file exists, else 000... +gitversion.h: +ifneq ("$(wildcard .git/index)","") + echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ +else + echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ +endif diff --git a/Makefile.Pi.HD44780 b/Makefile.Pi.HD44780 index a4b9c97..981af5e 100644 --- a/Makefile.Pi.HD44780 +++ b/Makefile.Pi.HD44780 @@ -15,12 +15,19 @@ OBJECTS = \ all: MMDVMHost -MMDVMHost: $(OBJECTS) +MMDVMHost: gitversion.h $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< clean: - $(RM) MMDVMHost *.o *.d *.bak *~ - + $(RM) MMDVMHost *.o *.d *.bak *~ gitversion.h + +# Export the current git version if the index file exists, else 000... +gitversion.h: +ifneq ("$(wildcard .git/index)","") + echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ +else + echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ +endif diff --git a/Makefile.Pi.OLED b/Makefile.Pi.OLED index 167c739..660fc88 100644 --- a/Makefile.Pi.OLED +++ b/Makefile.Pi.OLED @@ -15,12 +15,19 @@ OBJECTS = \ all: MMDVMHost -MMDVMHost: $(OBJECTS) +MMDVMHost: gitversion.h $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< clean: - $(RM) MMDVMHost *.o *.d *.bak *~ - + $(RM) MMDVMHost *.o *.d *.bak *~ gitversion.h + +# Export the current git version if the index file exists, else 000... +gitversion.h: +ifneq ("$(wildcard .git/index)","") + echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ +else + echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ +endif diff --git a/Makefile.Pi.PCF8574 b/Makefile.Pi.PCF8574 index e5df3a5..2ea81dd 100644 --- a/Makefile.Pi.PCF8574 +++ b/Makefile.Pi.PCF8574 @@ -15,11 +15,19 @@ OBJECTS = \ all: MMDVMHost -MMDVMHost: $(OBJECTS) +MMDVMHost: gitversion.h $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< clean: - $(RM) MMDVMHost *.o *.d *.bak *~ + $(RM) MMDVMHost *.o *.d *.bak *~ gitversion.h + +# Export the current git version if the index file exists, else 000... +gitversion.h: +ifneq ("$(wildcard .git/index)","") + echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ +else + echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ +endif diff --git a/Makefile.Solaris b/Makefile.Solaris index a2c74ac..6113fa6 100644 --- a/Makefile.Solaris +++ b/Makefile.Solaris @@ -15,12 +15,19 @@ OBJECTS = \ all: MMDVMHost -MMDVMHost: $(OBJECTS) +MMDVMHost: gitversion.h $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< clean: - $(RM) MMDVMHost *.o *.d *.bak *~ - + $(RM) MMDVMHost *.o *.d *.bak *~ gitversion.h + +# Export the current git version if the index file exists, else 000... +gitversion.h: +ifneq ("$(wildcard .git/index)","") + echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ +else + echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ +endif