blob: eccc47c5ca5cf61cef64c3bcb424a31e67368378 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/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"
|