mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-21 20:11:12 +00:00
Merge branch 'comptime-no-fail' into 'master'
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.
This commit is contained in:
parent
84bc03d24e
commit
e6780f2bee
2 changed files with 24 additions and 34 deletions
54
comptime.sh
54
comptime.sh
|
@ -1,54 +1,44 @@
|
||||||
#!/bin/bash -e
|
#!/bin/sh
|
||||||
path="."
|
path="."
|
||||||
if [ x"$1" != x ]; then
|
if [ x"$1" != x ]; then
|
||||||
path="$1"
|
path="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
versiongit() {
|
version() {
|
||||||
gitbranch=`git rev-parse --abbrev-ref HEAD`
|
cat <<EOF > "$path/comptime.h"
|
||||||
gitversion=`git rev-parse HEAD`
|
|
||||||
cat <<EOF > $path/comptime.h
|
|
||||||
|
|
||||||
// Do not edit! This file was autogenerated
|
// Do not edit! This file was autogenerated
|
||||||
// by the $0 script with git
|
// by the $0 script with git
|
||||||
//
|
//
|
||||||
const char* compbranch = "$gitbranch";
|
const char* compbranch = "$1";
|
||||||
const char* comprevision = "${gitversion:0:8}";
|
const char* comprevision = "$2";
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
}
|
||||||
|
|
||||||
|
versiongit() {
|
||||||
|
gitbranch="$(git rev-parse --abbrev-ref HEAD)"
|
||||||
|
gitversion="$(git rev-parse HEAD | cut -c -8)"
|
||||||
|
version "$gitbranch" "$gitversion";
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
versionsvn() {
|
versionsvn() {
|
||||||
svnrevision=`svnversion -n $1`
|
svnrevision="$(svnversion -n "$1")"
|
||||||
cat <<EOF > $path/comptime.h
|
version "Subversion" "r$svnrevision";
|
||||||
|
exit 0
|
||||||
// Do not edit! This file was autogenerated
|
|
||||||
// by the $0 script with subversion
|
|
||||||
//
|
|
||||||
const char* compbranch = "Subversion";
|
|
||||||
const char* comprevision = "r$svnrevision";
|
|
||||||
EOF
|
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
versionfake() {
|
versionfake() {
|
||||||
cat <<EOF > $path/comptime.h
|
version "Unknown" "illegal";
|
||||||
|
|
||||||
// Do not edit! This file was autogenerated
|
|
||||||
// by the $0 script with an unknown or nonexist SCM
|
|
||||||
//
|
|
||||||
const char* compbranch = "Unknown";
|
|
||||||
const char* comprevision = "illegal";
|
|
||||||
EOF
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compversion() {
|
compversion() {
|
||||||
touch $path/comptime.c
|
touch "$path/comptime.c"
|
||||||
versionfake
|
versionfake
|
||||||
test -d $path/.svn && versionsvn
|
[ -d "$path/.svn" ] && versionsvn "$@"
|
||||||
test -d $path/../.git && versiongit
|
[ -d "$path/../.git" ] && versiongit
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
test -f $path/comptime.c && compversion
|
[ -f "$path/comptime.c" ] && compversion "$@"
|
||||||
exit 2
|
exit 2
|
||||||
|
|
|
@ -357,9 +357,9 @@ $(dbg).txt : $(dbg)
|
||||||
# this really updates comptime.h
|
# this really updates comptime.h
|
||||||
comptime.c ::
|
comptime.c ::
|
||||||
ifdef WINDOWSHELL
|
ifdef WINDOWSHELL
|
||||||
$(.)..\comptime.bat .
|
-$(.)..\comptime.bat .
|
||||||
else
|
else
|
||||||
$(.)../comptime.sh .
|
-$(.)../comptime.sh .
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# I wish I could make dependencies out of rc files :(
|
# I wish I could make dependencies out of rc files :(
|
||||||
|
|
Loading…
Reference in a new issue