Show the builds commit ID during boot

This commit is contained in:
wiidev 2020-07-09 02:12:46 +01:00
parent 78c2fbce22
commit 6f653db8a5
4 changed files with 45 additions and 3 deletions

View File

@ -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)))

25
gitver.sh Normal file
View File

@ -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 <<EOF > ./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

View File

@ -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});

15
source/gitver.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef GITVER_H
#define GITVER_H
#ifdef __cplusplus
extern "C"
{
#endif
const char *commitID();
#ifdef __cplusplus
}
#endif
#endif