-
Notifications
You must be signed in to change notification settings - Fork 75
/
gather_build_info
executable file
·66 lines (56 loc) · 1.2 KB
/
gather_build_info
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
machine=$(uname -m) > /dev/null 2>&1
if [ "$?" != "0" ]
then
machine="unknown-machine"
fi
os=$(uname -o) > /dev/null 2>&1
if [ "$?" != "0" ]
then
# check for mac OSX (this could probably be done better)
uname -a | grep '^Darwin ' > /dev/null 2>&1
if [ "$?" = "0" ]
then
os="Darwin"
else
os="unknown-os"
fi
fi
diffcount="0"
git_hash=$(git rev-parse HEAD) > /dev/null 2>&1
if [ "$?" != "0" ]
then
git_hash="unknown-git-hash"
else
diffcount=$(git diff 2>&1 | wc -c)
if [ "$?" != "0" ]
then
diffcount='?'
fi
fi
if [ "$diffcount" = "0" ]
then
diffsummary=""
else
diffsummary="+ $diffcount"
fi
# today=$(date '+%Y-%m-%d %H:%M:%S')
# if [ "$?" != "0" ]
# then
# today="unknown"
# fi
endianness=$(bin/check-endianness)
if [ "$?" != "0" ]
then
endianness="unknown-wordsize unknown-endianness"
fi
protocol_version=$(awk '/SNIS_PROTOCOL_VERSION/ { print $3; }' < snis.h | sed -e 's/"//g')
cat << EOF
#ifndef __BUILD_INFO
#define __BUILD_INFO
/* This file is machine generated */
#define BUILD_INFO_STRING1 "v. " SNIS_VERSION " - $endianness $machine $os"
#define BUILD_INFO_STRING2 "$protocol_version $git_hash $diffsummary"
#define BUILD_INFO_STRING3 "SPACE NERDS IN SPACE v. " SNIS_VERSION
#endif
EOF