SRB2/comptime.sh

45 lines
746 B
Bash
Raw Normal View History

#!/bin/sh
2014-03-15 16:59:03 +00:00
path="."
if [ x"$1" != x ]; then
path="$1"
fi
version() {
cat <<EOF > "$path/comptime.h"
2014-03-15 16:59:03 +00:00
// Do not edit! This file was autogenerated
// by the $0 script with git
2014-03-15 16:59:03 +00:00
//
const char* compbranch = "$1";
const char* comprevision = "$2";
2014-03-15 16:59:03 +00:00
EOF
}
versiongit() {
gitbranch="$(git rev-parse --abbrev-ref HEAD)"
gitversion="$(git rev-parse HEAD | cut -c -8)"
version "$gitbranch" "$gitversion";
exit 0
}
2014-03-15 16:59:03 +00:00
versionsvn() {
svnrevision="$(svnversion -n $1)"
version "Subversion" "r$svnrevision";
exit 0
2014-03-15 16:59:03 +00:00
}
versionfake() {
version "Unknown" "illegal";
2014-03-15 16:59:03 +00:00
}
compversion() {
touch "$path/comptime.c"
versionfake
[ -d "$path/.svn" ] && versionsvn
[ -d "$path/../.git" ] && versiongit
exit 1
2014-03-15 16:59:03 +00:00
}
[ -f "$path/comptime.c" ] && compversion
2014-03-15 16:59:03 +00:00
exit 2