From d8e55ec6a601c4533d5a394df38842e9ec4c5751 Mon Sep 17 00:00:00 2001 From: Oliver Bock <oliver.bock@aei.mpg.de> Date: Wed, 4 May 2011 11:41:12 +0200 Subject: [PATCH] Added version info feature --- build.sh | 28 ++++++++++++++++++++++++++++ src/starsphere/main.cpp | 15 ++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 9770921..f0da51f 100755 --- a/build.sh +++ b/build.sh @@ -176,6 +176,34 @@ prepare_tree() } +prepare_version_header() +{ + HEADER_FILE="$ROOT/src/erp_git_version.h" + + cd $ROOT || failure + + echo "Retrieving git version information..." | tee -a $LOGFILE + + if [ -d .git ]; then + GIT_LOG=`git log -n1 --pretty="format:%H"` || failure + HOST=`hostname` || failure + fi + + echo "#ifndef ERP_GIT_VERSION_H" > $HEADER_FILE || failure + echo "#define ERP_GIT_VERSION_H" >> $HEADER_FILE || failure + echo "" >> $HEADER_FILE || failure + + if [ "no$GIT_LOG" != "no" ]; then + echo "#define ERP_GIT_VERSION \"$GIT_LOG ($HOST:$PWD)\"" >> $HEADER_FILE || failure + else + echo "#define ERP_GIT_VERSION \"unknown (git repository not found!)\"" >> $HEADER_FILE || failure + fi + + echo "" >> $HEADER_FILE || failure + echo "#endif" >> $HEADER_FILE || failure +} + + prepare_mingw() { if [ $BUILDSTATE -ge $BS_PREPARE_MINGW ]; then diff --git a/src/starsphere/main.cpp b/src/starsphere/main.cpp index 4647e95..66b96fc 100644 --- a/src/starsphere/main.cpp +++ b/src/starsphere/main.cpp @@ -24,6 +24,8 @@ #include <diagnostics.h> #include <boinc_api.h> +#include "../erp_git_version.h" + #include "WindowManager.h" #include "ResourceFactory.h" #include "AbstractGraphicsEngine.h" @@ -43,7 +45,18 @@ extern "C" { int main(int argc, char **argv) { - // enable BOINC diagnostics + // print version info + if(argc == 2) { + string param(argv[1]); + if(param == "--version" || param = "-v") { + cout << "Version information:" << endl; + cout << "Graphics Application Revision: " << ERP_GIT_VERSION << endl; + cout << "BOINC Revision: " << SVN_VERSION << endl; + exit(0); + } + } + + // enable BOINC diagnostics // TODO: we might want to optimize this for glibc- and mingw-based stacktraces! boinc_init_graphics_diagnostics(BOINC_DIAG_DEFAULTS); -- GitLab