mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-14 17:01:07 +00:00
e6780f2bee
Minor comptime refactoring. See merge request STJr/SRB2!1776 (cherry picked from commitdc02339cc9
)9bfc82a1
Prevent comptime.* from failing compilationa614865d
Make comptime.sh conform to POSIX and less redundant, among other improvementsb7711b2b
Pass argument list directly to functions that use them; quote arguments when used.
44 lines
758 B
Bash
Executable file
44 lines
758 B
Bash
Executable file
#!/bin/sh
|
|
path="."
|
|
if [ x"$1" != x ]; then
|
|
path="$1"
|
|
fi
|
|
|
|
version() {
|
|
cat <<EOF > "$path/comptime.h"
|
|
|
|
// Do not edit! This file was autogenerated
|
|
// by the $0 script with git
|
|
//
|
|
const char* compbranch = "$1";
|
|
const char* comprevision = "$2";
|
|
EOF
|
|
}
|
|
|
|
versiongit() {
|
|
gitbranch="$(git rev-parse --abbrev-ref HEAD)"
|
|
gitversion="$(git rev-parse HEAD | cut -c -8)"
|
|
version "$gitbranch" "$gitversion";
|
|
exit 0
|
|
}
|
|
|
|
versionsvn() {
|
|
svnrevision="$(svnversion -n "$1")"
|
|
version "Subversion" "r$svnrevision";
|
|
exit 0
|
|
}
|
|
|
|
versionfake() {
|
|
version "Unknown" "illegal";
|
|
}
|
|
|
|
compversion() {
|
|
touch "$path/comptime.c"
|
|
versionfake
|
|
[ -d "$path/.svn" ] && versionsvn "$@"
|
|
[ -d "$path/../.git" ] && versiongit
|
|
exit 1
|
|
}
|
|
|
|
[ -f "$path/comptime.c" ] && compversion "$@"
|
|
exit 2
|