From eec293e14714b3ca35eb187867c3f0cb6cf2cd10 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Thu, 30 Dec 2021 18:36:33 +0100 Subject: [PATCH] Tweak versioning reporting --- APRSWriterThread.cpp | 5 +++-- DStarGatewayApp.cpp | 4 ++-- Makefile | 8 ++++++-- Version.h | 7 ++++++- VersionUnit.cpp | 6 +++--- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/APRSWriterThread.cpp b/APRSWriterThread.cpp index 5e2b73c..fe27a9b 100644 --- a/APRSWriterThread.cpp +++ b/APRSWriterThread.cpp @@ -26,6 +26,7 @@ #include "Utils.h" #include "Defs.h" #include "Log.h" +#include "Version.h" // #define DUMP_TX @@ -44,7 +45,7 @@ m_reconnectTimer(1000U), m_tries(0U), m_APRSReadCallback(NULL), m_filter(""), -m_clientName("DStarGateway") +m_clientName(FULL_PRODUCT_NAME) { assert(!callsign.empty()); assert(!password.empty()); @@ -249,7 +250,7 @@ bool CAPRSWriterThread::connect() std::stringstream connectString; connectString << "User " << m_username << "-" << m_ssid << " pass " << m_password - << " vers " << (m_clientName.length() ? m_clientName : "DStarGateway") + << " vers " << (!m_clientName.empty() ? m_clientName : FULL_PRODUCT_NAME) << filter; //CLog::logInfo("Connect String : ") + connectString); ret = m_socket.writeLine(connectString.str()); diff --git a/DStarGatewayApp.cpp b/DStarGatewayApp.cpp index d5a450e..2668861 100644 --- a/DStarGatewayApp.cpp +++ b/DStarGatewayApp.cpp @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) } if ('-' == argv[1][0]) { - printf("\nDStarGateway Version %s (GitID #%.7s) Copyright (C) %s\n", VERSION.c_str(), gitversion, VENDOR_NAME.c_str()); + printf("\n%s Copyright (C) %s\n", FULL_PRODUCT_NAME.c_str(), VENDOR_NAME.c_str()); printf("DStarGateway comes with ABSOLUTELY NO WARRANTY; see the LICENSE for details.\n"); printf("This is free software, and you are welcome to distribute it\nunder certain conditions that are discussed in the LICENSE file.\n\n"); return 0; @@ -91,7 +91,7 @@ void CDStarGatewayApp::run() bool CDStarGatewayApp::createThread() { - printf("\nDStarGateway Version %s (GitID #%.7s) Copyright (C) %s\n", VERSION.c_str(), gitversion, VENDOR_NAME.c_str()); + printf("\n%s Copyright (C) %s\n", FULL_PRODUCT_NAME.c_str(), VENDOR_NAME.c_str()); printf("DStarGateway comes with ABSOLUTELY NO WARRANTY; see the LICENSE for details.\n"); printf("This is free software, and you are welcome to distribute it\nunder certain conditions that are discussed in the LICENSE file.\n\n"); diff --git a/Makefile b/Makefile index efa44c5..d959810 100644 --- a/Makefile +++ b/Makefile @@ -48,9 +48,13 @@ dstargateway : GitVersion.h $(OBJS) GitVersion.h : FORCE ifneq ("$(wildcard .git/index)","") - @echo "#pragma once\nconst char *gitversion = \"$(shell git rev-parse HEAD)\";" > /tmp/$@ + @echo "#pragma once" > /tmp/$@ + @echo "#include " >> /tmp/$@ + @echo "const std::string gitversion(\"$(shell git rev-parse --short HEAD)\");" >> /tmp/$@ else - @echo "#pragma once\nconst char *gitversion = \"0000000000000000000000000000000000000000\";" > /tmp/$@ + @echo "#pragma once" > /tmp/$@ + @echo "#include " >> /tmp/$@ + @echo "const std::string gitversion(\"0000000\");" >> /tmp/$@ endif @cmp -s /tmp/$@ $@; \ RETVAL=$$?; \ diff --git a/Version.h b/Version.h index a785f4f..e888470 100644 --- a/Version.h +++ b/Version.h @@ -22,5 +22,10 @@ #include -const std::string VENDOR_NAME("Geoffrey Merck F4FXL / KC3FRA"); +#include "GitVersion.h" + +const std::string PRODUCT_NAME("DStarGateway"); +const std::string VENDOR_NAME("Geoffrey Merck F4FXL / KC3FRA and Contributors"); const std::string VERSION("0.4"); +const std::string FULL_PRODUCT_NAME = PRODUCT_NAME + " v" + VERSION + "-" + gitversion; +const std::string SHORT_PRODUCT_NAME = "DStarGW v" + VERSION + "-" + gitversion; diff --git a/VersionUnit.cpp b/VersionUnit.cpp index 36ea096..a382039 100644 --- a/VersionUnit.cpp +++ b/VersionUnit.cpp @@ -45,13 +45,13 @@ m_out(0U) m_data = new CAMBEData*[NUM_FRAMES]; - char vstr[32]; - snprintf(vstr, 32, "DStar GW - %s", VERSION.substr(0, 8).c_str()); + auto vstr = SHORT_PRODUCT_NAME; + vstr.resize(NUM_FRAMES, ' '); CLog::logInfo("Version text set to \"%s\"\n", vstr); CSlowDataEncoder encoder; - encoder.setTextData(std::string(vstr)); + encoder.setTextData(vstr); // Seq No and end for (unsigned int i = 0U; i < NUM_FRAMES; i++) {