forked from smcameron/space-nerds-in-space
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gather_build_info
executable file
·63 lines (54 loc) · 1.03 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
#!/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=$(./check-endianness)
if [ "$?" != "0" ]
then
endianness="unknown-wordsize unknown-endianness"
fi
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 "$today $git_hash $diffsummary"
#endif
EOF