2022-11-16 02:38:04 +00:00
|
|
|
#!/bin/sh
|
2014-03-15 16:59:03 +00:00
|
|
|
path="."
|
|
|
|
if [ x"$1" != x ]; then
|
|
|
|
path="$1"
|
|
|
|
fi
|
|
|
|
|
2022-11-16 02:38:04 +00:00
|
|
|
version() {
|
|
|
|
cat <<EOF > "$path/comptime.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// Do not edit! This file was autogenerated
|
2016-01-14 12:31:48 +00:00
|
|
|
// by the $0 script with git
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
2022-11-16 02:38:04 +00:00
|
|
|
const char* compbranch = "$1";
|
|
|
|
const char* comprevision = "$2";
|
2023-12-06 03:54:59 +00:00
|
|
|
const char* compnote = "$3";
|
2014-03-15 16:59:03 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2022-11-16 02:38:04 +00:00
|
|
|
versiongit() {
|
|
|
|
gitbranch="$(git rev-parse --abbrev-ref HEAD)"
|
|
|
|
gitversion="$(git rev-parse HEAD | cut -c -8)"
|
2023-12-31 15:56:37 +00:00
|
|
|
gitsubject="$(git log -1 --format=%f)"
|
2023-12-06 03:54:59 +00:00
|
|
|
version "$gitbranch" "$gitversion" "$gitsubject";
|
2022-11-16 02:38:04 +00:00
|
|
|
exit 0
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2022-11-16 02:38:04 +00:00
|
|
|
versionsvn() {
|
|
|
|
svnrevision="$(svnversion -n "$1")"
|
2023-12-06 03:54:59 +00:00
|
|
|
version "Subversion" "r$svnrevision" "dummy";
|
2022-11-16 02:38:04 +00:00
|
|
|
exit 0
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
versionfake() {
|
2023-12-06 03:54:59 +00:00
|
|
|
version "Unknown" "illegal" "dummy";
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
compversion() {
|
2022-11-16 02:38:04 +00:00
|
|
|
touch "$path/comptime.c"
|
|
|
|
versionfake
|
|
|
|
[ -d "$path/.svn" ] && versionsvn "$@"
|
|
|
|
[ -d "$path/../.git" ] && versiongit
|
|
|
|
exit 1
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 02:38:04 +00:00
|
|
|
[ -f "$path/comptime.c" ] && compversion "$@"
|
2014-03-15 16:59:03 +00:00
|
|
|
exit 2
|