1
0
Fork 0

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
master
Chipster 3 years ago
parent c05a7f0205
commit e792cab308

1
.gitignore vendored

@ -17,3 +17,4 @@ DGIdGateway/DGIdGateway
YSFGateway/YSFGateway YSFGateway/YSFGateway
YSFParrot/YSFParrot YSFParrot/YSFParrot
YSFReflector/YSFReflector YSFReflector/YSFReflector
GitVersion.h

@ -14,9 +14,22 @@ YSFReflector: $(OBJECTS)
%.o: %.cpp %.o: %.cpp
$(CXX) $(CFLAGS) -c -o $@ $< $(CXX) $(CFLAGS) -c -o $@ $<
YSFReflector.o: GitVersion.h FORCE
.PHONY: GitVersion.h
FORCE:
install: install:
install -m 755 YSFReflector /usr/local/bin/ install -m 755 YSFReflector /usr/local/bin/
clean: 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

@ -23,6 +23,7 @@
#include "Version.h" #include "Version.h"
#include "Thread.h" #include "Thread.h"
#include "Log.h" #include "Log.h"
#include "GitVersion.h"
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
#include <Windows.h> #include <Windows.h>
@ -58,7 +59,7 @@ int main(int argc, char** argv)
for (int currentArg = 1; currentArg < argc; ++currentArg) { for (int currentArg = 1; currentArg < argc; ++currentArg) {
std::string arg = argv[currentArg]; std::string arg = argv[currentArg];
if ((arg == "-v") || (arg == "--version")) { if ((arg == "-v") || (arg == "--version")) {
::fprintf(stdout, "YSFReflector version %s\n", VERSION); ::fprintf(stdout, "YSFReflector version %s git #%.7s\n", VERSION, gitversion);
return 0; return 0;
} else if (arg.substr(0, 1) == "-") { } else if (arg.substr(0, 1) == "-") {
::fprintf(stderr, "Usage: YSFReflector [-v|--version] [filename]\n"); ::fprintf(stderr, "Usage: YSFReflector [-v|--version] [filename]\n");
@ -191,7 +192,8 @@ void CYSFReflector::run()
CTimer pollTimer(1000U, 5U); CTimer pollTimer(1000U, 5U);
pollTimer.start(); 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); CTimer watchdogTimer(1000U, 0U, 1500U);

Loading…
Cancel
Save