diff --git a/Makefile b/Makefile index 21b1adfd..63cba680 100644 --- a/Makefile +++ b/Makefile @@ -100,6 +100,7 @@ export DEPSDIR := $(CURDIR)/$(BUILD) # automatically build a list of object files for our project #--------------------------------------------------------------------------------- SVNREV := $(shell bash ./svnrev.sh) +GITVER := $(shell bash ./gitver.sh) IMPORTFILES := $(shell bash ./filelist.sh) export CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) export CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) diff --git a/gitver.sh b/gitver.sh new file mode 100644 index 00000000..2796e426 --- /dev/null +++ b/gitver.sh @@ -0,0 +1,25 @@ +#! /bin/bash +commit_id=$(git rev-parse --short=7 HEAD 2>/dev/null) +[ -z "$commit_id" ] && commit_id="0000001" +commit_message=$(git show -s --format="%<(52,trunc)%s" $commit_id 2>/dev/null | sed -e 's/[[:space:]]*$//') +[ -z "$commit_message" ] && commit_message="unable to get the commit message" +commit_id_old=$(cat ./source/gitver.c 2>/dev/null | tr -d '\n' | sed -r 's/.*([0-9a-f]{7}).*/\1/') + +if [ "$commit_id" != "$commit_id_old" ] || [ ! -f ./source/gitver.c ]; then + +cat < ./source/gitver.c +#define GIT_HASH "$commit_id" + +const char *commitID() +{ + return GIT_HASH; +} +EOF + + if [ -z "$commit_id_old" ]; then + echo "Created gitver.c and set the commit ID to $commit_id ($commit_message)" >&2 + else + echo "Changed the commit ID from $commit_id_old to $commit_id ($commit_message)" >&2 + fi + echo >&2 +fi diff --git a/source/StartUpProcess.cpp b/source/StartUpProcess.cpp index d02e26f9..1f3bef77 100644 --- a/source/StartUpProcess.cpp +++ b/source/StartUpProcess.cpp @@ -25,6 +25,7 @@ #include "utils/tools.h" #include "sys.h" #include "svnrev.h" +#include "gitver.h" extern bool isWiiVC; // in sys.cpp @@ -53,13 +54,13 @@ StartUpProcess::StartUpProcess() versionTxt->SetPosition(20, screenheight-20); #ifdef FULLCHANNEL - versionTxt->SetTextf("v3.0c Rev. %s", GetRev()); + versionTxt->SetTextf("v3.0c Rev. %s (%s)", GetRev(), commitID()); #else - versionTxt->SetTextf("v3.0 Rev. %s", GetRev()); + versionTxt->SetTextf("v3.0 Rev. %s (%s)", GetRev(), commitID()); #endif #if 1 // enable if you release a modded version - enabled by default to differentiate official releases - versionTxt->SetTextf("v3.0 Rev. %s mod", GetRev()); + versionTxt->SetTextf("v3.0 Rev. %s mod (%s)", GetRev(), commitID()); #endif cancelTxt = new GuiText("Press B to cancel", 18, (GXColor) {255, 255, 255, 255}); diff --git a/source/gitver.h b/source/gitver.h new file mode 100644 index 00000000..1c8adff5 --- /dev/null +++ b/source/gitver.h @@ -0,0 +1,15 @@ +#ifndef GITVER_H +#define GITVER_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + const char *commitID(); + +#ifdef __cplusplus +} +#endif + +#endif