Debian Codegraph @

build/build_all

raw symbols SCIP
1 #!/bin/bash
2
3 # process command line arguments. By default build all configurations
4 # (aka. nightly build)
5 #
6 case "$1" in
7
8 "") # default: build all configurations
9 configs="$configs standard"
10 configs="$configs develop"
11 configs="$configs tar"
12 # configs="$configs git"
13 configs="$configs libxcb"
14 configs="$configs rational"
15 configs="$configs libapl"
16 configs="$configs parallel_bench"
17 configs="$configs erlang"
18 configs="$configs python"
19 ;;
20
21 "clean") # clean up everything
22 configs=""
23 ;;
24
25 "nightly") # only refresh /var/www/html/nightly_build_results.html
26 configs=""
27 ;;
28
29 *)
30 configs="$*"
31 esac
32
33 echo "configs requested: $configs"
34
35 # this script builds different GNU APL variants and tests some of them
36
37 # First of all, figure and normalize some directory names:
38 #
39 # START_dir:
40 # the current directory from which this script was called.
41 # Used to cd back when all is done. In a nightly build, START_dir is
42 # probably /etc/cron.daily.
43 #
44 # TOP_BUILD_dir:
45 # the top-level directory that contains this script. The different
46 # configurations produced by this script are stored in corresponding
47 # subdirectories, e.g. in builddir_standard for configuration "standard"
48 #
49 # Example: /home/username/apl-1.9/build
50 #
51 # TOP_LOG_dir:
52 # the directory where top-level logfiles produced by the builds are stored.
53 # Normally TOP_LOG_dir is the same as TOP_BUILD_dir
54 #
55 # ROOT_dir:
56 # the GNU APL top-level directory. This is the one and only
57 # directory than contains the ./configure script for GNU APL.
58 # Normally # TOP_BUILD_dir is $ROOT_dir/build.
59 #
60 # Example: /home/username/apl-1.9
61 #
62 # APL_VERSION:
63 # the current version (including the 'apl-' prefix).
64 #
65 # Example: apl-1.9
66 #
67 # VSRC_dir:
68 # this is (despite of its name 'src' the destination directory for a single
69 # configuration. For example: the VSRC_dir for configuration "standard" is:
70 # $TOP_BUILD_dir/build/builddir_standard/src
71 #
72 # Example: /home/username/apl-1.9/src
73 #
74 START_dir=$(pwd) # e.g. /etc/cron.daily
75
76 cd $(dirname $0) # e.g. /root/apl-1.9
77 TOP_BUILD_dir=$(pwd)
78 SVN_VERSION=$(svnversion)
79
80 # NOTE: -j8 fails with out of memory on small hosts (like those
81 # used for nightly builds). By setting J8="" we avoid that
82 J8="-j8"
83 J8=""
84
85 # TOP_LOG_dir="/tmp" # where to store longer build logs
86 TOP_LOG_dir="$TOP_BUILD_dir" # where to store longer build logs
87
88 ROOT_dir=$(dirname $TOP_BUILD_dir)
89 APL_VERSION=$(basename $ROOT_dir)
90
91 # some counters for what happens
92 declare -i build_errors=0
93 declare -i missing_files=0
94 declare -i configs_bad=0
95 declare -i configs_good=0
96 declare -i test_errors=0
97 bad_configs=""
98
99 # print the.html table row for one build artifact
100 # print nothing if the artifact does not exist
101 #
102 artifact()
103 {
104 local indent=" " # <TR> indentation
105 local htmlname="$1" # description (TD1)
106 local filename="$2" # anchor text
107 local linkname="$3" # anchor href (name of a symbolic link to $2
108 # in /var/www/html/
109
110 local TD1="<TD><b>$htmlname</b> : </TD>"
111 local TD2="<TD><A href=\"$linkname\">$filename</A><$1</TD>"
112 local noTD2="<TD>missing (<b>$linkname</b>: No such file or directory)<$1</TD>"
113
114 if [ -f $linkname ]
115 then
116 echo "
117 $indent <TR>
118 $indent $TD1
119 $indent $TD2
120 $indent </TR>
121 "
122 else
123 echo "
124 $indent <TR>
125 $indent $TD1
126 $indent $noTD2
127 $indent </TR>
128 "
129 fi
130 }
131
132 write_nightly_build_results()
133 {
134 # produce a .html file with the nightly build result. We do not
135 # add the </body> and </html> end tags because we (and also the
136 # /etc/cron.daily/znightly_build_apl script) will append to the .html
137 # file later on
138 #
139 if [ -d /var/www/html ]
140 then
141 {
142 echo "<!DOCTYPE html>
143 <html>
144 <head>
145 <title>Nightly Build Results for GNU APL</title>
146 <meta charset="UTF-8"/>
147 </head>
148 <body>
149 <H1><center>Nightly Build Results for GNU APL</center></H1>
150 <HR>
151 Build date: $(date)<br><br>
152 SVN version: $SVN_VERSION<br><br>
153 $build_errors build errors<br>
154 $missing_files missing files (build results)<br>
155 $configs_bad configurations failed: $bad_configs<br>
156 $configs_good configurations succeeded<br>
157 $test_errors testcases failed<br>
158 "
159
160 echo "<H3>Nightly Build Artifacts (if any)</H3>
161 <TABLE>"
162 artifact "GNU APL interpreter" "apl" "apl"
163 artifact "libapl.so (shared library)" "build/xxx" "libapl.so"
164 artifact "libapl.a (static library)" "build/xxx" "libapl.a"
165 echo "</TABLE>"
166 echo "<H3>Other</H3>"
167
168 } > /var/www/html/nightly_build_results.html
169 fi
170 }
171 # refresh /var/www/html/nightly_build_results.html
172 if [ "x$1" = "xnightly" ]
173 then
174 write_nightly_build_results
175 exit 0
176 fi
177
178 # new run (takes a long timr)
179
180 # remove old build results and start a fresh summary file
181 #
182 rm -f "$TOP_BUILD_dir"/apl-*
183 rm -f "$TOP_BUILD_dir"/*.so
184 rm -f "$TOP_LOG_dir"/*.log
185 rm -f "$TOP_LOG_dir"/*.log2
186 rm -Rf builddir_*
187
188 # the user can clean this directory up by calling this script with
189 # argument 'clean'
190 #
191 [ "x$1" = "xclean" ] && exit 0
192
193 # check that the ROOT_dir is not ./configure'd. Otherwise ./configure would
194 # complain.
195 #
196 if [ -f "$ROOT_dir/config.status" ]
197 then
198 echo "*** $ROOT_dir is not clean. Please run 'make VPATH_clean' there."
199 exit 1
200 fi
201
202 ###################################################################
203 # build one configuration
204 #
205 build_one()
206 {
207 # $1: configuration name
208 # $2: ./configure options
209 # $3: expected result file (apl binary, libapl.so, etc.)
210 #
211
212 cd "$TOP_BUILD_dir"
213 rm -f "$3" # remove stale build results (should not exist)
214 rm -Rf "builddir_$1"
215 mkdir "builddir_$1"
216 cd "builddir_$1" # like the top-level directory in a non-VPATH build
217 VSRC_dir="$TOP_BUILD_dir/builddir_$1/src"
218
219 local time_FROM=$(date +%s)
220 local Logfile=$TOP_LOG_dir/configure-$1.log
221 echo
222 echo "running ../../configure for configuration: \"$1\"..."
223 echo " └─── see result in: $Logfile"
224 {
225 set -o xtrace
226 ../../configure $2
227 set +o xtrace
228 } > "$Logfile" 2>&1
229
230 Logfile="$TOP_LOG_dir/build-$1.log"
231 echo "running make $J8 all for configuration \"$1\"..."
232 echo " └─── see result in: $Logfile"
233
234 {
235 echo "building \"$1\"..."
236
237 make $J8 all
238 } > "$Logfile" 2>&1
239
240 local make_result=$?
241 local time_TO=$(date +%s)
242 local secs=$(( $time_TO - $time_FROM ))
243 local summ="$TOP_LOG_dir/summary.log"
244 local OK_failed="OK"
245 if [ $make_result -eq 0 ] ; then # make succeeded
246 echo " make OK for configuration: $1" >> $summ
247 if [ -f "$VSRC_dir/apl" ] ; then
248 cp -f "$VSRC_dir/apl" "/var/www/html/apl--$1"
249 mv -f "$VSRC_dir/apl" "$TOP_BUILD_dir/apl--$1"
250 configs_good=$((configs_good+1))
251 elif [ -f "$VSRC_dir/.libs/libapl.so" ] ; then
252 cp -f "$VSRC_dir/.libs/libapl.so" "/var/www/html/libapl.so"
253 mv -f "$VSRC_dir/.libs/libapl.so" "$TOP_BUILD_dir/"
254 configs_good=$((configs_good+1))
255 elif [ -f "$VSRC_dir/.libs/lib_gnu_apl.so" ] ; then
256 cp -f "$VSRC_dir/.libs/lib_gnu_apl.so" "/var/www/html/lib_gnu_apl.so"
257 mv -f "$VSRC_dir/.libs/lib_gnu_apl.so" "$TOP_BUILD_dir/"
258 configs_good=$((configs_good+1))
259 elif [ ! -f $3 ] ; then
260 echo "**** no file $3 after building $1" >> $summ
261 missing_files=$((missing_files+1))
262 configs_bad=$((configs_bad+1))
263 bad_configs="$bad_configs $1"
264 OK_failed="FAILED (make target missing)"
265 fi
266 echo " build $1: OK ($secs seconds)" >> $summ
267 else # make failed
268 echo "make FAILED with exit code: $make_result" >> $summ
269 echo "*** build $1: FAILED ($secs seconds)" >> $summ
270 echo "!!! configure options were: $2"
271 build_errors=$((build_errors+1))
272 configs_bad=$((configs_bad+1))
273 bad_configs="$bad_configs $1"
274 OK_failed="FAILED (make failed)"
275 fi
276 echo " configuration: \"$1\" done." >> $summ
277 echo " configuration: \"$1\" done ($OK_failed)"
278 }
279
280 ###################################################################
281 # test one configuration
282 #
283 test_one()
284 {
285 echo "testing configuration \"$1\"..."
286 echo " └─── see test results in: $VSRC_dir/testcases/summary.log"
287
288 local time_FROM=$(date +%s)
289 local summ="$TOP_LOG_dir/summary.log"
290 cd $VSRC_dir
291 cp $ROOT_dir/src/testcases/* testcases/ # copy testcases
292 cp $ROOT_dir/src/workspaces/* workspaces/ # needed by testcases
293 make test > /dev/null 2>&1
294 local make_result=$?
295 local time_TO=$(date +%s)
296 local secs=$(( $time_TO - $time_FROM ))
297 if [ $make_result -eq 0 ] ; then
298 echo " test $1: OK ($secs seconds)" >> $summ
299 else
300 echo "*** test $1: FAILED ($secs seconds)" >> $summ
301 test_errors=$((1+$test_errors))
302 fi
303 }
304
305 cd $ROOT_dir
306 echo "running autoreconf in $ROOT_dir..."
307 autoreconf
308 if [ "$?" != 0 ]; then
309 echo "*** cannot build all since autoreconf failed ***"
310 exit 42
311 fi
312 echo " ├─── autoreconf done (OK)."
313
314 # some shortcuts for various configure options
315 #
316 STD="--enable-maintainer-mode"
317 LIBAPL="--with-libapl"
318 PYTHON="--with-python"
319 ERLANG="--with-erlang"
320 DEV="DEVELOP_WANTED=yes"
321 RAT="RATIONAL_NUMBERS_WANTED=yes"
322
323 PERF="PERFORMANCE_COUNTERS_WANTED=yes"
324 DYLO="DYNAMIC_LOG_WANTED=yes"
325 XCB="--without-gtk3"
326 CC_3="CORE_COUNT_WANTED=-3" # ⎕SYL controls the number of cores
327 noVC="VALUE_CHECK_WANTED=no"
328 noVH="VALUE_HISTORY_WANTED=no"
329 AL0="ASSERT_LEVEL_WANTED=0" # no ASSERTions
330 FAST="$noVC $noVH $AL0"
331
332 ################################################################################
333 # build the standard configuration
334 #
335 build_standard()
336 {
337 build_one "standard" "$STD" "$VSRC_dir/apl"
338 test_one "standard"
339 }
340
341 # build the standard configuration from the GNU APL tar file
342 build_tar()
343 {
344 echo "building configuration 'standard' from the GNU APL tar file"
345 echo "the APL_VERSION is: $APL_VERSION"
346 cd $TOP_BUILD_dir
347 tar xf $ROOT_dir/$APL_VERSION.tar.gz
348 mv $APL_VERSION builddir_tar
349 cd builddir_tar
350 ./configure
351 make $J8
352 cd $TOP_BUILD_dir
353 }
354
355 # build the standard configuration from a git checkout
356 build_git()
357 {
358 echo "building configuration 'standard' from the git repository"
359 git clone https://git.savannah.gnu.org/git/apl.git builddir_git
360 cd builddir_git
361 ./configure
362 make $J8
363 }
364
365 #
366 build_libxcb()
367 {
368 build_one "libxcb" "$STD $XCB" "$VSRC_dir/apl"
369 test_one "standard"
370 }
371
372 ################################################################################
373 # build the standard configuration with libxcb (even if GTK3 is present)
374 #
375 build_libxcb()
376 {
377 build_one "libxcb" "$STD $XCB" "$VSRC_dir/apl"
378 test_one "standard"
379 }
380
381 # build the developer configuration with rational number support
382 #
383 build_rational()
384 {
385 build_one "rational" "$STD $DEV $RAT" "$VSRC_dir/apl"
386 }
387 ################################################################################
388 # build apl as a library
389 #
390 build_libapl()
391 {
392 build_one "libapl" "$STD $LIBAPL" "$VSRC_dir/.libs/libapl.so"
393 }
394 ################################################################################
395 # build the python interface to APL
396 #
397 build_python()
398 {
399 build_one "python" "$STD $PYTHON" "$VSRC_dir/.libs/lib_gnu_apl.so"
400 }
401 ################################################################################
402 # build apl for parallel benchmarking
403 #
404 build_parallel_bench()
405 {
406 build_one "parallel_bench" "$STD $FAST $PERF $DYLO $CC_3" "$VSRC_dir/apl"
407 }
408 ################################################################################
409 # build the erlang interface to APL
410 #
411 build_erlang()
412 {
413 build_one "erlang" "$STD $ERLANG" "$VSRC_dir/.libs/erlang_APL_nif.so"
414 }
415 ################################################################################
416 # build the developer configuration.
417 #
418 build_develop()
419 {
420 build_one "develop" "$STD $DEV" "$VSRC_dir/apl"
421 test_one "develop"
422 }
423
424 # build all relevant configurations
425 {
426 # clear the summary files
427 #
428 echo "Build Summary:" > "$TOP_LOG_dir/summary.log"
429 echo "Build Summary Errors:" 2> "$TOP_LOG_dir/summary.log2"
430
431 for config in $configs
432 do
433 echo -n " ├─── building configuration $config..." > /dev/stderr
434 build_$config
435 echo " done" > /dev/stderr
436 done
437 echo " └─── DONE." > /dev/stderr
438
439 echo
440 echo "$build_errors build errors"
441 echo "$missing_files missing files (build results)"
442 [ ! -z "$bad_configs" ] && echo "$configs_bad configurations failed: $bad_configs"
443 echo "$configs_good configurations succeeded"
444 echo "$test_errors testcases failed"
445 } >> "$TOP_LOG_dir/summary.log" 2>> "$TOP_LOG_dir/summary.log2"
446
447 cat "$TOP_LOG_dir/summary.log"
448
449 write_nightly_build_results
450
451 cd $START_dir # undo all cds in this script
452 stty sane # in case some testcase failed badly
453