diff --git a/build.sh b/build.sh index 9770921f0b31c33b089d525549fc92e6a979ec58..f0da51f6ef525a5eb273b07c754a6323fdcf7079 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 4647e9548b03d2fb697ec6bf57d3ed51cb838a94..66b96fc7bfbe597052b0692d334641b47c9e462f 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);