From 6c08b4b5be8ebfd149f29b20ab71e5a39773cb08 Mon Sep 17 00:00:00 2001 From: bushing Date: Sun, 10 May 2009 19:19:57 -0700 Subject: [PATCH] add git version numbers for ccat and MINI --- Makefile | 7 ++++++- describesimple.sh | 17 +++++++++++++++++ main.c | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100755 describesimple.sh diff --git a/Makefile b/Makefile index 3f9e297..8906d54 100644 --- a/Makefile +++ b/Makefile @@ -19,15 +19,20 @@ include ../../common.mk all: $(TARGET_BIN) +main.o: main.c git_version.h + $(TARGET_BIN): $(TARGET) $(ELFLOADER) @echo "MAKEBIN $@" @$(MAKEBIN) $(ELFLOADER) $< $@ upload: $(TARGET_BIN) @$(WIIDEV)/bin/bootmii -a $< + +git_version.h: + echo 'const char git_version[] = "'`./describesimple.sh`'";' > git_version.h clean: myclean myclean: - -rm -f $(TARGET_BIN) + -rm -f $(TARGET_BIN) git_version.h diff --git a/describesimple.sh b/describesimple.sh new file mode 100755 index 0000000..5ddd37d --- /dev/null +++ b/describesimple.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Check for git and a git repo. +if head=`git rev-parse --verify HEAD 2>/dev/null`; then + comm=`git log --pretty=oneline -n1 ../mini | awk ' { print $1 }'` + if tagver=`git describe --exact-match --match bootmii-\* $comm 2>/dev/null`; then + printf "%s" "BootMii v"`printf "%s" $tagver | awk '{ sub (/bootmii-/, ""); print;}'` + else + printf "%s" ""`printf "%s" \`git describe --abbrev=4 --match bootmii-\* $comm | awk '{ sub (/bootmii-/, ""); print;}'\`` + fi + + # Are there uncommitted changes? + git update-index --refresh --unmerged > /dev/null + git diff-index --quiet HEAD ../mini || printf "%s" '*' +fi + +echo diff --git a/main.c b/main.c index 58ca32e..ecee918 100644 --- a/main.c +++ b/main.c @@ -38,6 +38,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "crypto.h" #include "nand.h" #include "boot2.h" +#include "git_version.h" #define PPC_BOOT_FILE "/bootmii/ppcboot.elf" @@ -51,7 +52,7 @@ u32 _main(void *base) (void)base; gecko_init(); - gecko_printf("mini v0.2 loading\n"); + gecko_printf("mini v0.2 (%s) loading\n", git_version); gecko_printf("Initializing exceptions...\n"); exception_initialize();