From e792cab308dcfc7f47699f8f65fe0ade96a83b79 Mon Sep 17 00:00:00 2001 From: Chipster Date: Fri, 7 Jan 2022 09:14:33 -0600 Subject: [PATCH] Added git version string to VERSION, etc. (GitVersion.h); consistent with other clients. Added '--version|-v' to YSFParrot, as well as GitVersion.h facility Added GitVersion.h to gitignore --- .gitignore | 1 + YSFReflector/Makefile | 15 ++++++++++++++- YSFReflector/YSFReflector.cpp | 6 ++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index cead316..adbb599 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ DGIdGateway/DGIdGateway YSFGateway/YSFGateway YSFParrot/YSFParrot YSFReflector/YSFReflector +GitVersion.h diff --git a/YSFReflector/Makefile b/YSFReflector/Makefile index 2676fc1..076375a 100644 --- a/YSFReflector/Makefile +++ b/YSFReflector/Makefile @@ -14,9 +14,22 @@ YSFReflector: $(OBJECTS) %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +YSFReflector.o: GitVersion.h FORCE + +.PHONY: GitVersion.h + +FORCE: + install: install -m 755 YSFReflector /usr/local/bin/ clean: - $(RM) YSFReflector *.o *.d *.bak *~ + $(RM) YSFReflector *.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/YSFReflector/YSFReflector.cpp b/YSFReflector/YSFReflector.cpp index 1e8ce31..7f71aca 100644 --- a/YSFReflector/YSFReflector.cpp +++ b/YSFReflector/YSFReflector.cpp @@ -23,6 +23,7 @@ #include "Version.h" #include "Thread.h" #include "Log.h" +#include "GitVersion.h" #if defined(_WIN32) || defined(_WIN64) #include @@ -58,7 +59,7 @@ int main(int argc, char** argv) for (int currentArg = 1; currentArg < argc; ++currentArg) { std::string arg = argv[currentArg]; if ((arg == "-v") || (arg == "--version")) { - ::fprintf(stdout, "YSFReflector version %s\n", VERSION); + ::fprintf(stdout, "YSFReflector version %s git #%.7s\n", VERSION, gitversion); return 0; } else if (arg.substr(0, 1) == "-") { ::fprintf(stderr, "Usage: YSFReflector [-v|--version] [filename]\n"); @@ -191,7 +192,8 @@ void CYSFReflector::run() CTimer pollTimer(1000U, 5U); pollTimer.start(); - LogMessage("Starting YSFReflector-%s", VERSION); + LogMessage("YSFReflector-%s is starting", VERSION); + LogMessage("Built %s %s (GitID #%.7s)", __TIME__, __DATE__, gitversion); CTimer watchdogTimer(1000U, 0U, 1500U);