-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'comptime-no-fail' into 'master'
Minor comptime refactoring. See merge request STJr/SRB2!1776 (cherry picked from commit dc02339) 9bfc82a Prevent comptime.* from failing compilation a614865 Make comptime.sh conform to POSIX and less redundant, among other improvements b7711b2 Pass argument list directly to functions that use them; quote arguments when used.
- Loading branch information
1 parent
84bc03d
commit e6780f2
Showing
2 changed files
with
24 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,44 @@ | ||
#!/bin/bash -e | ||
#!/bin/sh | ||
path="." | ||
if [ x"$1" != x ]; then | ||
path="$1" | ||
fi | ||
|
||
versiongit() { | ||
gitbranch=`git rev-parse --abbrev-ref HEAD` | ||
gitversion=`git rev-parse HEAD` | ||
cat <<EOF > $path/comptime.h | ||
version() { | ||
cat <<EOF > "$path/comptime.h" | ||
// Do not edit! This file was autogenerated | ||
// by the $0 script with git | ||
// | ||
const char* compbranch = "$gitbranch"; | ||
const char* comprevision = "${gitversion:0:8}"; | ||
const char* compbranch = "$1"; | ||
const char* comprevision = "$2"; | ||
EOF | ||
exit 0 | ||
} | ||
|
||
versionsvn() { | ||
svnrevision=`svnversion -n $1` | ||
cat <<EOF > $path/comptime.h | ||
versiongit() { | ||
gitbranch="$(git rev-parse --abbrev-ref HEAD)" | ||
gitversion="$(git rev-parse HEAD | cut -c -8)" | ||
version "$gitbranch" "$gitversion"; | ||
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 | ||
versionsvn() { | ||
svnrevision="$(svnversion -n "$1")" | ||
version "Subversion" "r$svnrevision"; | ||
exit 0 | ||
} | ||
|
||
versionfake() { | ||
cat <<EOF > $path/comptime.h | ||
// 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 | ||
version "Unknown" "illegal"; | ||
} | ||
|
||
compversion() { | ||
touch $path/comptime.c | ||
versionfake | ||
test -d $path/.svn && versionsvn | ||
test -d $path/../.git && versiongit | ||
exit 1 | ||
touch "$path/comptime.c" | ||
versionfake | ||
[ -d "$path/.svn" ] && versionsvn "$@" | ||
[ -d "$path/../.git" ] && versiongit | ||
exit 1 | ||
} | ||
|
||
test -f $path/comptime.c && compversion | ||
[ -f "$path/comptime.c" ] && compversion "$@" | ||
exit 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters