From 96046c01f0b11f8280146c75afe55fcbdbeba0b8 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 20 Nov 2024 11:18:41 -0800 Subject: [PATCH] Adds MaikoGitVersion string to vdate.o The variable MaikoGitVersion will contain a git revision from the head of the source tree along with an indication if the status was "dirty". If git is not present on the system or the directory that the build happened in was not under git control the version will be "none". --- bin/mkvdate | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/mkvdate b/bin/mkvdate index 2c4b514..b440183 100755 --- a/bin/mkvdate +++ b/bin/mkvdate @@ -1,6 +1,22 @@ #!/bin/sh +if command -v "git" >/dev/null 2>&1; then + MAIKO_REV="$(git status --porcelain)" + if [ $? == 0 ]; then + if [ ! -z "$(git status --porcelain)" ]; then + MAIKO_REV="$(git rev-parse --short HEAD)-dirty" + else + MAIKO_REV="$(git rev-parse --short HEAD)" + fi + else + MAIKO_REV="none" + fi +else + MAIKO_REV = "none" +fi cat < extern const time_t MDate; const time_t MDate = $(date +%s); +extern const char *MaikoGitVersion; +const char *MaikoGitVersion = "maiko git version: $MAIKO_REV"; EOF