SRB2/comptime.sh

47 lines
857 B
Bash
Raw Permalink 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";
const char* compnote = "$3";
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)"
gitsubject="$(git log -1 --format=%f)"
version "$gitbranch" "$gitversion" "$gitsubject";
exit 0
}
2014-03-15 16:59:03 +00:00
versionsvn() {
svnrevision="$(svnversion -n "$1")"
version "Subversion" "r$svnrevision" "dummy";
exit 0
2014-03-15 16:59:03 +00:00
}
versionfake() {
version "Unknown" "illegal" "dummy";
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