-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathhiobuild
executable file
·187 lines (167 loc) · 5.34 KB
/
hiobuild
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#! /bin/bash
# -*- Mode: sh; sh-basic-offset:2 ; indent-tabs-mode:nil -*-
#
# Copyright (c) 2014-2016 Los Alamos National Security, LLC. All rights
# reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
#----------------------------------------------------------------------------
# hiobuild - build libhio from source tree
#
# Change History:
# 20150428 cgw Initial version
#----------------------------------------------------------------------------
synexit() {
echo ""
if [[ -n $* ]]; then echo $*; echo ""; fi
echo "hiobuild - build libhio and check results"
echo ""
echo " Syntax:"
echo " hiobuild [-acfx] [-d dir] [-n name]"
echo " [-l module]... [-s oldmod,newmod]..."
echo " [-h]"
echo ""
echo " Options:"
echo " -a Run autogen (implies -c)"
echo " -c Run configure (implies -f)"
echo " -f Full build (make clean)"
echo " -x Build extras (docs and dist)"
echo " -d dir Build directory (default $dir)"
echo " -n name Build name for results messages"
echo " -l module Issue module load"
echo " -s oldmod,newmod Issue module swap"
echo " -h Display this help"
echo ""
echo " Results logged to $logfn"
echo ""
echo " Cornell Wright cornell@lanl.gov"
exit 8
}
cmd() {
echo "`date \"$datefmt\"` $host ---> $*" 2>&1 | tee -a $log
eval $* 2>&1 | tee -a $log
}
msg() {
echo "`date \"$datefmt\"` $host $*" 2>&1 | tee -a $log
}
# Set up temporary log directory and file
datefmt="+%Y-%m-%d %H:%M:%S"
logfn="hiobuild.out"
tdir=$(mktemp -d /tmp/hiobuild.tmp.XXXX)
log="$tdir/$logfn"
host=`hostname -s`
args=$*
msg "hiobuild $args: Starting"
if [[ ${OSTYPE:0:6} != "darwin" ]]; then
. $MODULESHOME/init/bash
mod_script="hiobuild.modules.bash"
echo "# Created by hiobuild at `date`" > $mod_script
echo ". \$MODULESHOME/init/bash" >> $mod_script
echo "module list" >> $mod_script
else
mod_script=""
fi
#----------------------------------------------------------------------------
# Parse arguments
#----------------------------------------------------------------------------
autogen=0
configure=0
full=0
extra=0
dir=$(dirname ${BASH_SOURCE[0]}) # -d defaults to location of this script
name=""
while getopts "hacfxd:l:s:n:" optname; do
case $optname in
h ) synexit;;
a ) autogen=1;;
c ) configure=1;;
f ) full=1;;
x ) extra=1;;
d ) dir=$OPTARG;;
l ) modload=$OPTARG
echo "---> module load $modload" 2>&1 | tee -a $log
module load $modload
if [[ -n $mod_script ]]; then echo "module load $modload" >> $mod_script; fi
;;
s ) modswap=(${OPTARG//,/ })
echo "---> module swap ${modswap[*]}" 2>&1 | tee -a $log
module swap ${modswap[*]}
if [[ -n $mod_script ]]; then echo "module swap ${modswap[*]}" >> $mod_script; fi
;;
n ) name=$OPTARG;;
\? ) synexit "Error: invalid option";;
esac
done
shift $((OPTIND - 1 ))
if [[ -n $1 ]]; then synexit "Error: extra parameters"; fi
if [[ -n $mod_script ]]; then
echo "module list" >> $mod_script
echo "# --- end ---" >> $mod_script
fi
# Move log file to build directory
if [[ ! -d $dir ]]; then synexit "Error: directory $dir does not exist"; fi
msg "---> cd $dir"
cd $dir
mv -f $log .
log="$PWD/$logfn"
rm -fR $tdir
#----------------------------------------------------------------------------
# Build hio
#----------------------------------------------------------------------------
msg "hiobuild $args: Starting build at `date`"
if [[ ${OSTYPE:0:6} != "darwin" ]]; then cmd module list; fi
if [[ $autogen -gt 0 ]]; then
cmd ./autogen.sh
configure=1
fi
if [[ $configure -gt 0 ]]; then
cmd ./configure
full=1
fi;
if [[ $full -gt 0 ]]; then
cmd make clean
fi
cmd make
if [[ ${OSTYPE:0:6} == "darwin" ]]; then
files="src/.libs/libhio.1.dylib"
else
files="src/.libs/libhio.so.1.0.0"
fi
files="$files test/error_test.x test/.libs/test01.x test/.libs/hio_example.x test/xexec/.libs/xexec.x"
if [[ $extra -gt 0 ]]; then
cmd make docs
files="$files design/libhio_api.pdf"
cmd make dist
fi
#----------------------------------------------------------------------------
# Check log for errors, check for output files
#----------------------------------------------------------------------------
msg "====[HIOBUILD_RESULT_START]===($name)==========================================="
msg "hiobuild $name: Checking $log for build problems"
sed1="s/error_test/err0r_test/g"
sed2="s/-Werror/-Werr0r/g"
sed3="s/-Wno-error/-Wno-err0r/g"
sed4="s/Warning: Linking the shared library libhio.la against the/W@rning: Linking the shared library libhio.la against the/g"
tmpfile="tmp.hiobuild.grep.out"
cat $log | sed -e $sed1 -e $sed2 -e "$sed3" -e "$sed4" | egrep -ni "error|warn|fail" 1>$tmpfile 2>&1
rc=$?
cat $tmpfile 2>&1 | tee -a $log
rm $tmpfile
msg "hiobuild $name: Checking for build target files"
for f in $files; do
if [[ ! -e $f ]]; then
msg "Error: $f does not exist"
rc=3
fi
done
if [[ $rc -eq 1 ]]; then msg "hiobuild $name: Build OK."
else msg "hiobuild $name: Build errors found, see above."
fi
msg "====[HIOBUILD_RESULT_END]===($name)============================================="
msg $bar
msg "hiobuild $name: Done at `date`"
# --- end of hiobuild ---