author | wenzelm |
Tue, 24 Jul 2012 13:22:06 +0200 | |
changeset 48474 | 5b9d79c6323b |
parent 48469 | 826a771cff33 |
child 48509 | 4854ced3e9d7 |
permissions | -rwxr-xr-x |
48276 | 1 |
#!/usr/bin/env bash |
2 |
# |
|
3 |
# Author: Makarius |
|
4 |
# |
|
5 |
# DESCRIPTION: build and manage Isabelle sessions |
|
6 |
||
7 |
||
8 |
## diagnostics |
|
9 |
||
10 |
PRG="$(basename "$0")" |
|
11 |
||
48474 | 12 |
function show_settings() |
13 |
{ |
|
14 |
local PREFIX="$1" |
|
15 |
echo "${PREFIX}ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\"" |
|
16 |
echo |
|
17 |
echo "${PREFIX}ML_PLATFORM=\"$ML_PLATFORM\"" |
|
18 |
echo "${PREFIX}ML_HOME=\"$ML_HOME\"" |
|
19 |
echo "${PREFIX}ML_SYSTEM=\"$ML_SYSTEM\"" |
|
20 |
echo "${PREFIX}ML_OPTIONS=\"$ML_OPTIONS\"" |
|
21 |
} |
|
22 |
||
48276 | 23 |
function usage() |
24 |
{ |
|
25 |
echo |
|
26 |
echo "Usage: isabelle $PRG [OPTIONS] [SESSIONS ...]" |
|
27 |
echo |
|
28 |
echo " Options are:" |
|
29 |
echo " -a all sessions" |
|
30 |
echo " -b build target images" |
|
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
31 |
echo " -d DIR additional session directory with ROOT file" |
48425 | 32 |
echo " -j INT maximum number of jobs (default 1)" |
48469 | 33 |
echo " -n no build -- test dependencies only" |
48276 | 34 |
echo " -o OPTION override session configuration OPTION (via NAME=VAL or NAME)" |
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
35 |
echo " -s system build mode: produce output in ISABELLE_HOME" |
48459
375e45df6fdf
timing is command line options, not system option;
wenzelm
parents:
48447
diff
changeset
|
36 |
echo " -t inner session timing" |
48425 | 37 |
echo " -v verbose" |
48276 | 38 |
echo |
39 |
echo " Build and manage Isabelle sessions, depending on implicit" |
|
48474 | 40 |
show_settings " " |
48276 | 41 |
echo |
42 |
exit 1 |
|
43 |
} |
|
44 |
||
45 |
function fail() |
|
46 |
{ |
|
47 |
echo "$1" >&2 |
|
48 |
exit 2 |
|
49 |
} |
|
50 |
||
48425 | 51 |
function check_number() |
52 |
{ |
|
53 |
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\"" |
|
54 |
} |
|
55 |
||
48276 | 56 |
|
57 |
## process command line |
|
58 |
||
59 |
ALL_SESSIONS=false |
|
60 |
BUILD_IMAGES=false |
|
48425 | 61 |
MAX_JOBS=1 |
48469 | 62 |
NO_BUILD=false |
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
63 |
SYSTEM_MODE=false |
48459
375e45df6fdf
timing is command line options, not system option;
wenzelm
parents:
48447
diff
changeset
|
64 |
TIMING=false |
48425 | 65 |
VERBOSE=false |
48276 | 66 |
|
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
67 |
declare -a MORE_DIRS=() |
48276 | 68 |
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)" |
69 |
||
48469 | 70 |
while getopts "abd:j:no:stv" OPT |
48276 | 71 |
do |
72 |
case "$OPT" in |
|
73 |
a) |
|
74 |
ALL_SESSIONS="true" |
|
75 |
;; |
|
76 |
b) |
|
77 |
BUILD_IMAGES="true" |
|
78 |
;; |
|
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
79 |
d) |
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
80 |
MORE_DIRS["${#MORE_DIRS[@]}"]="$OPTARG" |
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
81 |
;; |
48425 | 82 |
j) |
83 |
check_number "$OPTARG" |
|
84 |
MAX_JOBS="$OPTARG" |
|
85 |
;; |
|
48469 | 86 |
n) |
87 |
NO_BUILD="true" |
|
48276 | 88 |
;; |
89 |
o) |
|
90 |
BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG" |
|
91 |
;; |
|
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
92 |
s) |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
93 |
SYSTEM_MODE="true" |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
94 |
;; |
48459
375e45df6fdf
timing is command line options, not system option;
wenzelm
parents:
48447
diff
changeset
|
95 |
t) |
375e45df6fdf
timing is command line options, not system option;
wenzelm
parents:
48447
diff
changeset
|
96 |
TIMING="true" |
375e45df6fdf
timing is command line options, not system option;
wenzelm
parents:
48447
diff
changeset
|
97 |
;; |
48425 | 98 |
v) |
99 |
VERBOSE="true" |
|
100 |
;; |
|
48276 | 101 |
\?) |
102 |
usage |
|
103 |
;; |
|
104 |
esac |
|
105 |
done |
|
106 |
||
107 |
shift $(($OPTIND - 1)) |
|
108 |
||
109 |
||
110 |
## main |
|
111 |
||
112 |
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; } |
|
113 |
||
48474 | 114 |
if [ "$NO_BUILD" = false ]; then |
115 |
echo "Started at $(date) ($ML_IDENTIFIER on $(hostname))" |
|
116 |
||
117 |
if [ "$VERBOSE" = true ]; then |
|
118 |
show_settings "" |
|
119 |
echo |
|
120 |
fi |
|
121 |
. "$ISABELLE_HOME/lib/scripts/timestart.bash" |
|
122 |
fi |
|
123 |
||
124 |
"$ISABELLE_TOOL" java isabelle.Build \ |
|
48469 | 125 |
"$ALL_SESSIONS" "$BUILD_IMAGES" "$MAX_JOBS" "$NO_BUILD" "$SYSTEM_MODE" "$TIMING" \ |
48459
375e45df6fdf
timing is command line options, not system option;
wenzelm
parents:
48447
diff
changeset
|
126 |
"$VERBOSE" "${MORE_DIRS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@" |
48474 | 127 |
RC="$?" |
128 |
||
129 |
if [ "$NO_BUILD" = false ]; then |
|
130 |
echo -n "Finished at "; date |
|
131 |
||
132 |
. "$ISABELLE_HOME/lib/scripts/timestop.bash" |
|
133 |
echo "$TIMES_REPORT" |
|
134 |
fi |
|
135 |
||
136 |
exit "$RC" |