blob: eccc47c5ca5cf61cef64c3bcb424a31e67368378 (
plain) (
tree)
|
|
#!/bin/sh
export LANG=C
# Always create version string for repository this script lies in,
# not the cwd... Makes usage easier in cmake/out of source builds
ARG0="$0"
SELF="$(readlink -f "${ARG0}")"
if [ -n "$SELF" ]; then
ROOT_DIR="$(dirname "${SELF}")"
cd "$ROOT_DIR"
fi
MODDED=
[ -n "$(git diff)" ] && MODDED='+LOCALMOD'
VERSION=$(git describe || git rev-parse --short HEAD)
BUILDTIME=$(date -R)
COMMIT=$(git rev-parse HEAD)
COMMITTIME=$(git log -1 --date=short --pretty=format:%cD)
if [ -s ".localversion" ]; then
. .localversion
fi
VERSION="$VERSION$MODDED"
# replace
ssed() {
local fnd rep
fnd="%${1}%"
eval rep='"'\$$1'"'
sed "s/$fnd/$(echo "$rep" | sed 's,\\,\\\\,g;s,/,\\/,g')/g"
}
< "version.in" ssed "VERSION" | ssed "BUILDTIME" | ssed "COMMIT" | ssed "COMMITTIME" > "version.in.h"
|