author | wenzelm |
Mon, 04 Jan 2010 11:55:23 +0100 | |
changeset 34238 | b28be884edda |
parent 33830 | 1b634d37aa64 |
child 34261 | 8e36b3ac6083 |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2808 | 2 |
# |
9788 | 3 |
# Author: Markus Wenzel, TU Muenchen |
2808 | 4 |
# |
5 |
# DESCRIPTION: build object-logic or run examples |
|
6 |
||
7 |
||
8 |
## diagnostics |
|
9 |
||
10511 | 10 |
PRG="$(basename "$0")" |
2808 | 11 |
|
12 |
function usage() |
|
13 |
{ |
|
14 |
echo |
|
28650 | 15 |
echo "Usage: isabelle $PRG [OPTIONS] LOGIC NAME" |
2808 | 16 |
echo |
17 |
echo " Options are:" |
|
17194
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
18 |
echo " -C BOOL copy existing document directory to -D PATH (default true)" |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
19 |
echo " -D PATH dump generated document sources into PATH" |
23972 | 20 |
echo " -M MAX multithreading: maximum number of worker threads (default 1)" |
6940 | 21 |
echo " -P PATH set path for remote theory browsing information" |
24118 | 22 |
echo " -T LEVEL multithreading: trace level (default 0)" |
17050 | 23 |
echo " -V VERSION declare alternative document VERSION" |
6212 | 24 |
echo " -b build mode (output heap image, using current dir)" |
7737 | 25 |
echo " -d FORMAT build document as FORMAT (default false)" |
15269
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
26 |
echo " -f NAME use ML file NAME (default ROOT.ML)" |
11847 | 27 |
echo " -g BOOL generate session graph image for document (default false)" |
28 |
echo " -i BOOL generate HTML and graph browser information (default false)" |
|
10562 | 29 |
echo " -m MODE add print mode for output" |
32061
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
30 |
echo " -p LEVEL set level of detail for proof objects (default 0)" |
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
31 |
echo " -q LEVEL set level of parallel proof checking (default 1)" |
6212 | 32 |
echo " -r reset session path" |
2808 | 33 |
echo " -s NAME override session NAME" |
31688 | 34 |
echo " -t BOOL internal session timing (default false)" |
11577 | 35 |
echo " -v BOOL be verbose (default false)" |
2808 | 36 |
echo |
37 |
echo " Build object-logic or run examples. Also creates browsing" |
|
38 |
echo " information (HTML etc.) according to settings." |
|
39 |
echo |
|
7461 | 40 |
echo " ISABELLE_USEDIR_OPTIONS=$ISABELLE_USEDIR_OPTIONS" |
41 |
echo |
|
29089 | 42 |
echo " ML_PLATFORM=$ML_PLATFORM" |
43 |
echo " ML_HOME=$ML_HOME" |
|
44 |
echo " ML_SYSTEM=$ML_SYSTEM" |
|
45 |
echo " ML_OPTIONS=$ML_OPTIONS" |
|
46 |
echo |
|
2808 | 47 |
exit 1 |
48 |
} |
|
49 |
||
11577 | 50 |
function fail() |
51 |
{ |
|
52 |
echo "$1" >&2 |
|
53 |
exit 2 |
|
54 |
} |
|
55 |
||
56 |
function check_bool() |
|
57 |
{ |
|
58 |
[ "$1" = true -o "$1" = false ] || fail "Bad boolean: \"$1\"" |
|
59 |
} |
|
60 |
||
61 |
function check_number() |
|
62 |
{ |
|
12912 | 63 |
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\"" |
11577 | 64 |
} |
65 |
||
2808 | 66 |
|
67 |
## process command line |
|
68 |
||
69 |
# options |
|
70 |
||
24061 | 71 |
COPY_DUMP=true |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
72 |
DUMP="" |
23972 | 73 |
MAXTHREADS="1" |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
74 |
RPATH="" |
24118 | 75 |
TRACETHREADS="0" |
17050 | 76 |
DOCUMENT_VERSIONS="" |
2808 | 77 |
BUILD="" |
7737 | 78 |
DOCUMENT=false |
17050 | 79 |
ROOT_FILE="ROOT.ML" |
11847 | 80 |
DOCUMENT_GRAPH=false |
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
81 |
INFO=false |
10562 | 82 |
MODES="" |
6212 | 83 |
RESET=false |
2808 | 84 |
SESSION="" |
32061
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
85 |
PROOFS="0" |
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
86 |
PARALLEL_PROOFS="1" |
31688 | 87 |
TIMING=false |
11577 | 88 |
VERBOSE=false |
2808 | 89 |
|
2917 | 90 |
function getoptions() |
91 |
{ |
|
92 |
OPTIND=1 |
|
32061
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
93 |
while getopts "C:D:M:P:T:V:bd:f:g:i:m:p:q:rs:t:v:" OPT |
2917 | 94 |
do |
95 |
case "$OPT" in |
|
17194
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
96 |
C) |
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
97 |
check_bool "$OPTARG" |
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
98 |
COPY_DUMP="$OPTARG" |
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
99 |
;; |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
100 |
D) |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
101 |
DUMP="$OPTARG" |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
102 |
;; |
23972 | 103 |
M) |
25774 | 104 |
if [ "$OPTARG" = max ]; then |
29435
a5f84ac14609
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents:
29143
diff
changeset
|
105 |
MAXTHREADS=0 |
a5f84ac14609
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents:
29143
diff
changeset
|
106 |
else |
25774 | 107 |
check_number "$OPTARG" |
108 |
MAXTHREADS="$OPTARG" |
|
29435
a5f84ac14609
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents:
29143
diff
changeset
|
109 |
fi |
23972 | 110 |
;; |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
111 |
P) |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
112 |
RPATH="$OPTARG" |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
113 |
;; |
24061 | 114 |
T) |
24118 | 115 |
check_number "$OPTARG" |
24061 | 116 |
TRACETHREADS="$OPTARG" |
117 |
;; |
|
17050 | 118 |
V) |
119 |
if [ -z "$DOCUMENT_VERSIONS" ]; then |
|
120 |
DOCUMENT_VERSIONS="\"$OPTARG\"" |
|
121 |
else |
|
122 |
DOCUMENT_VERSIONS="$DOCUMENT_VERSIONS, \"$OPTARG\"" |
|
123 |
fi |
|
124 |
;; |
|
2917 | 125 |
b) |
126 |
BUILD=true |
|
127 |
;; |
|
7737 | 128 |
d) |
129 |
DOCUMENT="$OPTARG" |
|
130 |
;; |
|
15269
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
131 |
f) |
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
132 |
ROOT_FILE="$OPTARG" |
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
133 |
;; |
11847 | 134 |
g) |
135 |
check_bool "$OPTARG" |
|
136 |
DOCUMENT_GRAPH="$OPTARG" |
|
137 |
;; |
|
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
138 |
i) |
11577 | 139 |
check_bool "$OPTARG" |
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
140 |
INFO="$OPTARG" |
2917 | 141 |
;; |
10562 | 142 |
m) |
143 |
if [ -z "$MODES" ]; then |
|
144 |
MODES="\"$OPTARG\"" |
|
145 |
else |
|
10585 | 146 |
MODES="\"$OPTARG\", $MODES" |
10562 | 147 |
fi |
148 |
;; |
|
11535
7f4c5cdea239
Added new option for setting level of detail for proof objects.
berghofe
parents:
10585
diff
changeset
|
149 |
p) |
11577 | 150 |
check_number "$OPTARG" |
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11535
diff
changeset
|
151 |
PROOFS="$OPTARG" |
11535
7f4c5cdea239
Added new option for setting level of detail for proof objects.
berghofe
parents:
10585
diff
changeset
|
152 |
;; |
32061
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
153 |
q) |
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
154 |
check_number "$OPTARG" |
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
155 |
PARALLEL_PROOFS="$OPTARG" |
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
156 |
;; |
6212 | 157 |
r) |
158 |
RESET=true |
|
159 |
;; |
|
2917 | 160 |
s) |
161 |
SESSION="$OPTARG" |
|
162 |
;; |
|
31688 | 163 |
t) |
164 |
check_bool "$OPTARG" |
|
165 |
TIMING="$OPTARG" |
|
166 |
;; |
|
11577 | 167 |
v) |
168 |
check_bool "$OPTARG" |
|
169 |
VERBOSE="$OPTARG" |
|
170 |
;; |
|
2917 | 171 |
\?) |
172 |
usage |
|
173 |
;; |
|
174 |
esac |
|
175 |
done |
|
176 |
} |
|
2808 | 177 |
|
31307
7015fee8c3e8
ISABELLE_USEDIR_OPTIONS: proper word splitting of quoted options (via array variable and special expansion, cf. "$@");
wenzelm
parents:
29435
diff
changeset
|
178 |
eval "OPTIONS=($ISABELLE_USEDIR_OPTIONS)" |
7015fee8c3e8
ISABELLE_USEDIR_OPTIONS: proper word splitting of quoted options (via array variable and special expansion, cf. "$@");
wenzelm
parents:
29435
diff
changeset
|
179 |
getoptions "${OPTIONS[@]}" |
2917 | 180 |
|
181 |
getoptions "$@" |
|
2808 | 182 |
shift $(($OPTIND - 1)) |
183 |
||
184 |
||
185 |
# args |
|
186 |
||
9788 | 187 |
[ "$#" -ne 2 ] && usage |
2808 | 188 |
|
189 |
LOGIC="$1"; shift |
|
190 |
NAME="$1"; shift |
|
191 |
||
9788 | 192 |
[ -z "$SESSION" ] && SESSION=$(basename "$NAME") |
2808 | 193 |
|
4419 | 194 |
|
195 |
||
196 |
## main |
|
3636
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
197 |
|
4451 | 198 |
# prepare browser info dir |
4419 | 199 |
|
25235 | 200 |
if [ "$INFO" = "true" -a ! -f "$ISABELLE_BROWSER_INFO/index.html" ]; then |
9788 | 201 |
mkdir -p "$ISABELLE_BROWSER_INFO" |
202 |
cp "$ISABELLE_HOME/lib/logo/isabelle.gif" "$ISABELLE_BROWSER_INFO/isabelle.gif" |
|
25234 | 203 |
cat "$ISABELLE_HOME/lib/html/library_index_header.template" \ |
204 |
"$ISABELLE_HOME/lib/html/library_index_content.template" \ |
|
205 |
"$ISABELLE_HOME/lib/html/library_index_footer.template"> "$ISABELLE_BROWSER_INFO/index.html" |
|
3636
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
206 |
fi |
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
207 |
|
2808 | 208 |
|
4451 | 209 |
# prepare log dir |
210 |
||
211 |
LOGDIR="$ISABELLE_OUTPUT/log" |
|
212 |
mkdir -p "$LOGDIR" |
|
213 |
||
214 |
||
215 |
# run isabelle |
|
216 |
||
7737 | 217 |
PARENT=$(basename "$LOGIC") |
218 |
||
11949 | 219 |
if [ -z "$BUILD" ]; then |
220 |
cd "$NAME" || fail "Bad session directory '$NAME'" |
|
221 |
fi |
|
4451 | 222 |
|
11847 | 223 |
if [ "$DOCUMENT" != false ]; then |
8568 | 224 |
DOC="$DOCUMENT" |
225 |
else |
|
226 |
DOC="" |
|
227 |
fi |
|
7737 | 228 |
|
229 |
||
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
17194
diff
changeset
|
230 |
. "$ISABELLE_HOME/lib/scripts/timestart.bash" |
6249 | 231 |
|
2808 | 232 |
if [ -n "$BUILD" ]; then |
4451 | 233 |
ITEM="$SESSION" |
11577 | 234 |
echo "Building $ITEM ..." >&2 |
4451 | 235 |
LOG="$LOGDIR/$ITEM" |
236 |
||
28502 | 237 |
"$ISABELLE_PROCESS" \ |
31688 | 238 |
-e "Session.use_dir \"$ITEM\" \"$ROOT_FILE\" true [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH [$DOCUMENT_VERSIONS] \"$PARENT\" \"$SESSION\" ($COPY_DUMP, \"$DUMP\") \"$RPATH\" $PROOFS $TIMING $VERBOSE $MAXTHREADS $TRACETHREADS $PARALLEL_PROOFS;" \ |
31317
1f5740424c69
removed "compress" option from isabelle-process and isabelle usedir -- this is always enabled;
wenzelm
parents:
31307
diff
changeset
|
239 |
-q -w $LOGIC $NAME > "$LOG" |
9788 | 240 |
RC="$?" |
2808 | 241 |
else |
9788 | 242 |
ITEM=$(basename "$LOGIC")-"$SESSION" |
11577 | 243 |
echo "Running $ITEM ..." >&2 |
4451 | 244 |
LOG="$LOGDIR/$ITEM" |
245 |
||
28502 | 246 |
"$ISABELLE_PROCESS" \ |
31688 | 247 |
-e "Session.use_dir \"$ITEM\" \"$ROOT_FILE\" false [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH [$DOCUMENT_VERSIONS] \"$PARENT\" \"$SESSION\" ($COPY_DUMP, \"$DUMP\") \"$RPATH\" $PROOFS $TIMING $VERBOSE $MAXTHREADS $TRACETHREADS $PARALLEL_PROOFS; quit();" \ |
11577 | 248 |
-r -q "$LOGIC" > "$LOG" |
9788 | 249 |
RC="$?" |
6212 | 250 |
cd .. |
2808 | 251 |
fi |
4451 | 252 |
|
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
17194
diff
changeset
|
253 |
. "$ISABELLE_HOME/lib/scripts/timestop.bash" |
4451 | 254 |
|
255 |
||
256 |
# exit status |
|
257 |
||
9788 | 258 |
if [ "$RC" -eq 0 ]; then |
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
17194
diff
changeset
|
259 |
echo "Finished $ITEM ($TIMES_REPORT)" >&2 |
4451 | 260 |
gzip --force "$LOG" |
261 |
else |
|
11577 | 262 |
{ echo "$ITEM FAILED"; |
263 |
echo "(see also $LOG)"; |
|
33830 | 264 |
echo; tail -40 "$LOG"; echo; } >&2 |
4451 | 265 |
fi |
266 |
||
9788 | 267 |
exit "$RC" |