From d54efa8cb872b6ecc7657dd215efeeabf04821e1 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 30 Oct 2023 11:47:01 +0900 Subject: Add git hash to program version Signed-off-by: Michele Calgaro --- ConfigureChecks.cmake | 8 ++++++ config.h.cmake | 3 ++- src/AboutDialog.cpp | 6 ++--- src/CMakeLists.txt | 51 +++++++++++++++++++------------------- src/UiGuiVersion.cpp | 68 --------------------------------------------------- src/UiGuiVersion.h | 14 ++--------- src/main.cpp | 6 ++--- src/tclap/StdOutput.h | 2 +- 8 files changed, 43 insertions(+), 115 deletions(-) delete mode 100644 src/UiGuiVersion.cpp diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 253fd69..1ad873a 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -25,6 +25,14 @@ if( WITH_GCC_VISIBILITY ) endif( WITH_GCC_VISIBILITY ) +##### get commit hash information +execute_process( + COMMAND git describe --abbrev=8 --dirty --always + OUTPUT_VARIABLE GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + + ##### check for stream support check_cxx_source_compiles( diff --git a/config.h.cmake b/config.h.cmake index 0d0af75..bf4bed3 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1,4 +1,5 @@ -#define VERSION "@VERSION@" +#define VERSION "@VERSION@" +#define GIT_HASH "@GIT_HASH@" // application share location #define APP_SHARE_PATH "@SHARE_INSTALL_PREFIX@/universal-indent-gui-tqt" diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp index 9bb119d..e604852 100644 --- a/src/AboutDialog.cpp +++ b/src/AboutDialog.cpp @@ -52,8 +52,7 @@ AboutDialog::AboutDialog(TQWidget *parent, WFlags flags) : //---- //---- TQString versionString = _dialogForm->versionTextBrowser->toHtml(); //---- versionString = -//---- versionString.arg(PROGRAM_VERSION_STRING).arg(UiGuiVersion::getBuildRevision()).arg( -//---- UiGuiVersion::getBuildDate()); +//---- versionString.arg(PROGRAM_VERSION_STRING); //---- _dialogForm->versionTextBrowser->setHtml(versionString); //---- //---- _dialogForm->creditsTextBrowser->setHtml("" @@ -115,8 +114,7 @@ void AboutDialog::changeEvent(TQEvent *event) //---- //---- TQString versionString = _dialogForm->versionTextBrowser->toHtml(); //---- versionString = -//---- versionString.arg(PROGRAM_VERSION_STRING).arg(UiGuiVersion::getBuildRevision()).arg( -//---- UiGuiVersion::getBuildDate()); +//---- versionString.arg(PROGRAM_VERSION_STRING); //---- _dialogForm->versionTextBrowser->setHtml(versionString); //---- } //---- else diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84845f3..1744c4a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,9 +7,9 @@ ################################################# include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} ${TQT_INCLUDE_DIRS} ) @@ -26,31 +26,30 @@ link_directories( set( target universal-indent-gui-tqt ) set( ${target}_SRCS - # completed - MainWindowBase.ui - ToolBarWidget.ui - - IndentHandler.cpp - SettingsPaths.cpp - TemplateBatchScript.cpp - UiGuiErrorMessage.cpp - UiGuiHighlighter.cpp - UiGuiIniFileParser.cpp - UiGuiVersion.cpp - - # ongoing - AboutDialogBase.ui - UiGuiSettingsDialogBase.ui - - AboutDialog.cpp - MainWindow.cpp - main.cpp - UiGuiSettings.cpp - UiGuiSettingsDialog.cpp + # completed + MainWindowBase.ui + ToolBarWidget.ui + + IndentHandler.cpp + SettingsPaths.cpp + TemplateBatchScript.cpp + UiGuiErrorMessage.cpp + UiGuiHighlighter.cpp + UiGuiIniFileParser.cpp + + # ongoing + AboutDialogBase.ui + UiGuiSettingsDialogBase.ui + + AboutDialog.cpp + MainWindow.cpp + main.cpp + UiGuiSettings.cpp + UiGuiSettingsDialog.cpp ) tde_add_executable( ${target} AUTOMOC SOURCES ${${target}_SRCS} - LINK ${TQT_LIBRARIES} ${TQSCINTILLA_LIBRARIES} - DESTINATION ${BIN_INSTALL_DIR} + LINK ${TQT_LIBRARIES} ${TQSCINTILLA_LIBRARIES} + DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/src/UiGuiVersion.cpp b/src/UiGuiVersion.cpp deleted file mode 100644 index c996ff5..0000000 --- a/src/UiGuiVersion.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiVersion.h" - -#include -#include -#include - -namespace UiGuiVersion -{ - /*! - \brief Returns the build date as a localized string, e.g. "9. Februar 2009". If - there was some kind of error, the returned string is empty. - */ - TQString getBuildDate() - { - TQStringList monthNames; - monthNames << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" - << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; - - TQString buildDateString = ""; - // __DATE__ returns a string like "Feb 4 2009" - TQStringList buildDateStringList = TQStringList::split(' ', TQString(__DATE__).simplifyWhiteSpace()); - if (buildDateStringList.count() == 3) - { - TQDate buildDate(buildDateStringList.last().toInt(), - monthNames.findIndex(buildDateStringList.first()) + 1, - buildDateStringList.at(1)->toInt()); - buildDateString = buildDate.toString("d. MMMM yyyy"); - } - - return buildDateString; - } - - /*! - \brief Returns the revision number, that the current build is based on, as string. If - there was some kind of error, the returned string is empty. - */ - TQString getBuildRevision() - { - TQString buildRevision = ""; - TQStringList buildRevisionStringList = TQStringList::split(' ', TQString(PROGRAM_REVISION).simplifyWhiteSpace()); - - if (buildRevisionStringList.count() == 3) - { - buildRevision = *buildRevisionStringList.at(1); // PROGRAM_REVISION is eg "$Revision: 907 $" - } - - return buildRevision; - } -} diff --git a/src/UiGuiVersion.h b/src/UiGuiVersion.h index e01f512..cee8a06 100644 --- a/src/UiGuiVersion.h +++ b/src/UiGuiVersion.h @@ -20,19 +20,9 @@ #ifndef UIGUIVERSION_H #define UIGUIVERSION_H -class TQString; +#include "config.h" // Define the version number here. Update this as the last file before a release. -#define PROGRAM_VERSION 1.2.0 -#define PROGRAM_VERSION_STRING "1.2.0" -#define RESOURCE_VERSION 1, 2, 0, 0 -#define RESOURCE_VERSION_STRING "1,2,0,0\0" -#define PROGRAM_REVISION "$Revision: 1070 $" - -namespace UiGuiVersion -{ - TQString getBuildDate(); - TQString getBuildRevision(); -} +#define PROGRAM_VERSION_STRING "1.2.0-" GIT_HASH #endif diff --git a/src/main.cpp b/src/main.cpp index 38decad..c71d80f 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -65,8 +65,8 @@ int main(int argc, char *argv[]) { // Define the command line object. TCLAP::CmdLine cmd("If -p and -s are set, -p will be used.\n" - "Giving no parameters starts full gui without server.", ' ', - "UiGUI version " PROGRAM_VERSION_STRING " " PROGRAM_REVISION); + "Giving no parameters starts full gui without server.", + ' ', PROGRAM_VERSION_STRING); cmd.setExceptionHandling(false); // Define a value argument and add it to the command line. @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) // -- TSLogger::getInstance(verboseLevel); // -- #endif // -- qInstallMsgHandler(TSLogger::messageHandler); -// -- TSLogger::messageHandler(TSLoggerInfoMsg, TQString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toAscii()); +// -- TSLogger::messageHandler(TSLoggerInfoMsg, TQString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).toAscii()); // -- // Start normal with full gui and without server. if (!startAsPlugin && !startAsServer) { diff --git a/src/tclap/StdOutput.h b/src/tclap/StdOutput.h index 24b90ed..71a7ed8 100644 --- a/src/tclap/StdOutput.h +++ b/src/tclap/StdOutput.h @@ -99,7 +99,7 @@ namespace TCLAP std::string progName = _cmd.getProgramName(); std::string version = _cmd.getVersion(); - std::cout << std::endl << progName << " version: " << version << std::endl << std::endl; + std::cout << std::endl << progName << " version " << version << std::endl << std::endl; } inline void StdOutput::usage(CmdLineInterface &_cmd) -- cgit v1.2.1