author | wenzelm |
Mon, 30 Jul 2012 12:03:48 +0200 | |
changeset 48595 | 231e6fa96dbb |
parent 48594 | c24907e5081e |
child 48601 | 655b08c2cd89 |
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:" |
|
48570 | 29 |
echo " -a select all sessions" |
48511
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48509
diff
changeset
|
30 |
echo " -b build heap images" |
48595 | 31 |
echo " -c clean build" |
48509 | 32 |
echo " -d DIR include session directory with ROOT file" |
48570 | 33 |
echo " -g NAME select session group NAME" |
48578 | 34 |
echo " -j INT maximum number of parallel jobs (default 1)" |
48469 | 35 |
echo " -n no build -- test dependencies only" |
48276 | 36 |
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
|
37 |
echo " -s system build mode: produce output in ISABELLE_HOME" |
48425 | 38 |
echo " -v verbose" |
48276 | 39 |
echo |
40 |
echo " Build and manage Isabelle sessions, depending on implicit" |
|
48474 | 41 |
show_settings " " |
48276 | 42 |
echo |
43 |
exit 1 |
|
44 |
} |
|
45 |
||
46 |
function fail() |
|
47 |
{ |
|
48 |
echo "$1" >&2 |
|
49 |
exit 2 |
|
50 |
} |
|
51 |
||
48425 | 52 |
function check_number() |
53 |
{ |
|
54 |
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\"" |
|
55 |
} |
|
56 |
||
48276 | 57 |
|
58 |
## process command line |
|
59 |
||
60 |
ALL_SESSIONS=false |
|
48511
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48509
diff
changeset
|
61 |
BUILD_HEAP=false |
48595 | 62 |
CLEAN_BUILD=false |
48509 | 63 |
declare -a MORE_DIRS=() |
64 |
declare -a SESSION_GROUPS=() |
|
48425 | 65 |
MAX_JOBS=1 |
48469 | 66 |
NO_BUILD=false |
48509 | 67 |
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)" |
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
68 |
SYSTEM_MODE=false |
48425 | 69 |
VERBOSE=false |
48276 | 70 |
|
48595 | 71 |
while getopts "abcd:g:j:no:sv" OPT |
48276 | 72 |
do |
73 |
case "$OPT" in |
|
74 |
a) |
|
75 |
ALL_SESSIONS="true" |
|
76 |
;; |
|
77 |
b) |
|
48511
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48509
diff
changeset
|
78 |
BUILD_HEAP="true" |
48276 | 79 |
;; |
48595 | 80 |
c) |
81 |
CLEAN_BUILD="true" |
|
82 |
;; |
|
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
83 |
d) |
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
84 |
MORE_DIRS["${#MORE_DIRS[@]}"]="$OPTARG" |
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48276
diff
changeset
|
85 |
;; |
48509 | 86 |
g) |
87 |
SESSION_GROUPS["${#SESSION_GROUPS[@]}"]="$OPTARG" |
|
88 |
;; |
|
48425 | 89 |
j) |
90 |
check_number "$OPTARG" |
|
91 |
MAX_JOBS="$OPTARG" |
|
92 |
;; |
|
48469 | 93 |
n) |
94 |
NO_BUILD="true" |
|
48276 | 95 |
;; |
96 |
o) |
|
97 |
BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG" |
|
98 |
;; |
|
48447
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
99 |
s) |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
100 |
SYSTEM_MODE="true" |
ef600ce4559c
added system build mode: produce output in ISABELLE_HOME;
wenzelm
parents:
48425
diff
changeset
|
101 |
;; |
48425 | 102 |
v) |
103 |
VERBOSE="true" |
|
104 |
;; |
|
48276 | 105 |
\?) |
106 |
usage |
|
107 |
;; |
|
108 |
esac |
|
109 |
done |
|
110 |
||
111 |
shift $(($OPTIND - 1)) |
|
112 |
||
113 |
||
114 |
## main |
|
115 |
||
116 |
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; } |
|
117 |
||
48474 | 118 |
if [ "$NO_BUILD" = false ]; then |
119 |
echo "Started at $(date) ($ML_IDENTIFIER on $(hostname))" |
|
120 |
||
121 |
if [ "$VERBOSE" = true ]; then |
|
122 |
show_settings "" |
|
123 |
echo |
|
124 |
fi |
|
125 |
. "$ISABELLE_HOME/lib/scripts/timestart.bash" |
|
126 |
fi |
|
127 |
||
128 |
"$ISABELLE_TOOL" java isabelle.Build \ |
|
48595 | 129 |
"$ALL_SESSIONS" "$BUILD_HEAP" "$CLEAN_BUILD" "$MAX_JOBS" \ |
130 |
"$NO_BUILD" "$SYSTEM_MODE" "$VERBOSE" \ |
|
48509 | 131 |
"${MORE_DIRS[@]}" $'\n' "${SESSION_GROUPS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@" |
48474 | 132 |
RC="$?" |
133 |
||
134 |
if [ "$NO_BUILD" = false ]; then |
|
135 |
echo -n "Finished at "; date |
|
136 |
||
137 |
. "$ISABELLE_HOME/lib/scripts/timestop.bash" |
|
138 |
echo "$TIMES_REPORT" |
|
139 |
fi |
|
140 |
||
141 |
exit "$RC" |