-
Notifications
You must be signed in to change notification settings - Fork 35
/
runbuild.sh
executable file
·149 lines (130 loc) · 3.36 KB
/
runbuild.sh
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/sh
## 08-Jun-2010 (thich01)
## Added set -- to clear passed in arguments
## 17-Aug-2010 (thich01)
## Added quit op to allow jam to stop building on error by default. Changed
## response text to make it more clear.
# This is a simple script to help you run the build with less overhead.
# It will automatically set up your environment and run the build.
# It will log all logs to a timestamped log file.
#TODO
# - add online help
# - add automatic execution of sep tests
# - add automatic packaging
# - add cleanup and forced rebuild options (jam clean with -c) (jam force with -a)
# - add some additional sanity checks as issues are uncovered
NOW=`date +"%m_%d_%y_%H%M"`
PWD=`pwd`
LOGDIR="${PWD}/logs"
LOGFILE="${LOGDIR}/jam_${NOW}.log"
DEBUGOPT=""
REBUILDOPT=""
CLEANOPT=""
usage()
{
cat <<STOP
Usage: -a to force a rebuild (i.e. jam -a)
-c to clean a build (i.e. jam clean)
-g to compile with extra debugging information
-q to turn off the jam -q option, which will make jam complete the whole process, even when encountering an error.
-h for this help text.
STOP
}
QUITOPT="-q"
while getopts "acghq" options; do
case $options in
a ) REBUILDOPT="-a";;
c ) CLEANOPT="clean";;
g ) DEBUGOPT="-sIIOPTIM=-g";;
q ) QUITOPT="";;
h ) usage
exit 1;;
\? ) usage
exit 1;;
* ) usage
exit 1;;
esac
done
# Check to see where the rest of the build tools are
if [ -d ./buildtools ]
then
BUILDTOOLS="${PWD}/buildtools"
export BUILDTOOLS
fi
# Set a return code to success, we'll toggle it if anything fails
RETURN=0
if [ ! -d ${LOGDIR} ]
then
mkdir -p ${LOGDIR}
fi
# Clear $1 argument parms so that they are not passed
# to sourced scripts.
set --
# if we're starting fresh, set up the environment
if [ -f ${BUILDTOOLS}/set_env.sh ]
then
. ${BUILDTOOLS}/set_env.sh || exit 1
else
echo "Error, I cannot find the set_env.sh script"
echo "This is required to use runbuild.sh"
echo "Please run runbuild.sh from the root directory of the Ingres source"
exit 1
fi
if [ $CLEANOPT ]
then
cd $ING_SRC
date > ${LOGFILE}
jam $CLEANOPT >> ${LOGFILE} 2>&1
echo "Clean complete."
echo "Logs are in: ${LOGFILE}"
exit 0
fi
date > ${LOGFILE}
echo " "
echo "Starting Ingres build."
echo "This will take roughly 20 minutes or more."
echo "(depending on how fast your computer is)"
echo " "
echo "Use \"tail -f ${LOGFILE}\""
echo "in another terminal window to follow progress."
echo " "
echo "RESULTS:"
cd $ING_ROOT/src/tools/port/jam/; jam >> ${LOGFILE} 2>&1
cd $ING_SRC; mkjams >> ${LOGFILE} 2>&1
jam $QUITOPT $REBUILDOPT $DEBUGOPT >> ${LOGFILE} 2>&1
# Check if the build succeeded or failed by the presence of
# skipped or failed targets
grep "failed updating" ${LOGFILE} > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Some compile targets failed."
RETURN=1
else
echo "All compile targets were successful."
fi
grep "skipped" ${LOGFILE} > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Some compile targets were skipped."
RETURN=1
else
echo "All compile targets were executed."
fi
buildrel -a >> ${LOGFILE} 2>&1
if [ $? -eq 0 ]
then
echo "buildrel -a succeeded."
else
echo "buildrel -a failed."
RETURN=1
fi
echo " "
date >> ${LOGFILE}
if [ $RETURN -eq 0 ]
then
echo "The build succeeded."
else
echo "The build failed. Check the logs to determine why."
fi
echo "Logs are in: ${LOGFILE}"
exit ${RETURN}