author | bulwahn |
Sat, 24 Oct 2009 16:55:42 +0200 | |
changeset 33129 | 3085da75ed54 |
parent 32931 | 540e674ff184 |
child 33830 | 1b634d37aa64 |
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" |
24957 | 41 |
echo " HOL_USEDIR_OPTIONS=$HOL_USEDIR_OPTIONS" |
7461 | 42 |
echo |
29089 | 43 |
echo " ML_PLATFORM=$ML_PLATFORM" |
44 |
echo " ML_HOME=$ML_HOME" |
|
45 |
echo " ML_SYSTEM=$ML_SYSTEM" |
|
46 |
echo " ML_OPTIONS=$ML_OPTIONS" |
|
47 |
echo |
|
2808 | 48 |
exit 1 |
49 |
} |
|
50 |
||
11577 | 51 |
function fail() |
52 |
{ |
|
53 |
echo "$1" >&2 |
|
54 |
exit 2 |
|
55 |
} |
|
56 |
||
57 |
function check_bool() |
|
58 |
{ |
|
59 |
[ "$1" = true -o "$1" = false ] || fail "Bad boolean: \"$1\"" |
|
60 |
} |
|
61 |
||
62 |
function check_number() |
|
63 |
{ |
|
12912 | 64 |
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\"" |
11577 | 65 |
} |
66 |
||
2808 | 67 |
|
68 |
## process command line |
|
69 |
||
70 |
# options |
|
71 |
||
24061 | 72 |
COPY_DUMP=true |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
73 |
DUMP="" |
23972 | 74 |
MAXTHREADS="1" |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
75 |
RPATH="" |
24118 | 76 |
TRACETHREADS="0" |
17050 | 77 |
DOCUMENT_VERSIONS="" |
2808 | 78 |
BUILD="" |
7737 | 79 |
DOCUMENT=false |
17050 | 80 |
ROOT_FILE="ROOT.ML" |
11847 | 81 |
DOCUMENT_GRAPH=false |
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
82 |
INFO=false |
10562 | 83 |
MODES="" |
6212 | 84 |
RESET=false |
2808 | 85 |
SESSION="" |
32061
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
86 |
PROOFS="0" |
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
87 |
PARALLEL_PROOFS="1" |
31688 | 88 |
TIMING=false |
11577 | 89 |
VERBOSE=false |
2808 | 90 |
|
2917 | 91 |
function getoptions() |
92 |
{ |
|
93 |
OPTIND=1 |
|
32061
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
94 |
while getopts "C:D:M:P:T:V:bd:f:g:i:m:p:q:rs:t:v:" OPT |
2917 | 95 |
do |
96 |
case "$OPT" in |
|
17194
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
97 |
C) |
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
98 |
check_bool "$OPTARG" |
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
99 |
COPY_DUMP="$OPTARG" |
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
100 |
;; |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
101 |
D) |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
102 |
DUMP="$OPTARG" |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
103 |
;; |
23972 | 104 |
M) |
25774 | 105 |
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
|
106 |
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
|
107 |
else |
25774 | 108 |
check_number "$OPTARG" |
109 |
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
|
110 |
fi |
23972 | 111 |
;; |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
112 |
P) |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
113 |
RPATH="$OPTARG" |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
114 |
;; |
24061 | 115 |
T) |
24118 | 116 |
check_number "$OPTARG" |
24061 | 117 |
TRACETHREADS="$OPTARG" |
118 |
;; |
|
17050 | 119 |
V) |
120 |
if [ -z "$DOCUMENT_VERSIONS" ]; then |
|
121 |
DOCUMENT_VERSIONS="\"$OPTARG\"" |
|
122 |
else |
|
123 |
DOCUMENT_VERSIONS="$DOCUMENT_VERSIONS, \"$OPTARG\"" |
|
124 |
fi |
|
125 |
;; |
|
2917 | 126 |
b) |
127 |
BUILD=true |
|
128 |
;; |
|
7737 | 129 |
d) |
130 |
DOCUMENT="$OPTARG" |
|
131 |
;; |
|
15269
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
132 |
f) |
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
133 |
ROOT_FILE="$OPTARG" |
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
134 |
;; |
11847 | 135 |
g) |
136 |
check_bool "$OPTARG" |
|
137 |
DOCUMENT_GRAPH="$OPTARG" |
|
138 |
;; |
|
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
139 |
i) |
11577 | 140 |
check_bool "$OPTARG" |
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
141 |
INFO="$OPTARG" |
2917 | 142 |
;; |
10562 | 143 |
m) |
144 |
if [ -z "$MODES" ]; then |
|
145 |
MODES="\"$OPTARG\"" |
|
146 |
else |
|
10585 | 147 |
MODES="\"$OPTARG\", $MODES" |
10562 | 148 |
fi |
149 |
;; |
|
11535
7f4c5cdea239
Added new option for setting level of detail for proof objects.
berghofe
parents:
10585
diff
changeset
|
150 |
p) |
11577 | 151 |
check_number "$OPTARG" |
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11535
diff
changeset
|
152 |
PROOFS="$OPTARG" |
11535
7f4c5cdea239
Added new option for setting level of detail for proof objects.
berghofe
parents:
10585
diff
changeset
|
153 |
;; |
32061
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
154 |
q) |
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
155 |
check_number "$OPTARG" |
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
156 |
PARALLEL_PROOFS="$OPTARG" |
11f8ee55662d
parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
wenzelm
parents:
31688
diff
changeset
|
157 |
;; |
6212 | 158 |
r) |
159 |
RESET=true |
|
160 |
;; |
|
2917 | 161 |
s) |
162 |
SESSION="$OPTARG" |
|
163 |
;; |
|
31688 | 164 |
t) |
165 |
check_bool "$OPTARG" |
|
166 |
TIMING="$OPTARG" |
|
167 |
;; |
|
11577 | 168 |
v) |
169 |
check_bool "$OPTARG" |
|
170 |
VERBOSE="$OPTARG" |
|
171 |
;; |
|
2917 | 172 |
\?) |
173 |
usage |
|
174 |
;; |
|
175 |
esac |
|
176 |
done |
|
177 |
} |
|
2808 | 178 |
|
31307
7015fee8c3e8
ISABELLE_USEDIR_OPTIONS: proper word splitting of quoted options (via array variable and special expansion, cf. "$@");
wenzelm
parents:
29435
diff
changeset
|
179 |
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
|
180 |
getoptions "${OPTIONS[@]}" |
2917 | 181 |
|
182 |
getoptions "$@" |
|
2808 | 183 |
shift $(($OPTIND - 1)) |
184 |
||
185 |
||
186 |
# args |
|
187 |
||
9788 | 188 |
[ "$#" -ne 2 ] && usage |
2808 | 189 |
|
190 |
LOGIC="$1"; shift |
|
191 |
NAME="$1"; shift |
|
192 |
||
9788 | 193 |
[ -z "$SESSION" ] && SESSION=$(basename "$NAME") |
2808 | 194 |
|
4419 | 195 |
|
196 |
||
197 |
## main |
|
3636
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
198 |
|
4451 | 199 |
# prepare browser info dir |
4419 | 200 |
|
25235 | 201 |
if [ "$INFO" = "true" -a ! -f "$ISABELLE_BROWSER_INFO/index.html" ]; then |
9788 | 202 |
mkdir -p "$ISABELLE_BROWSER_INFO" |
203 |
cp "$ISABELLE_HOME/lib/logo/isabelle.gif" "$ISABELLE_BROWSER_INFO/isabelle.gif" |
|
25234 | 204 |
cat "$ISABELLE_HOME/lib/html/library_index_header.template" \ |
205 |
"$ISABELLE_HOME/lib/html/library_index_content.template" \ |
|
206 |
"$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
|
207 |
fi |
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
208 |
|
2808 | 209 |
|
4451 | 210 |
# prepare log dir |
211 |
||
212 |
LOGDIR="$ISABELLE_OUTPUT/log" |
|
213 |
mkdir -p "$LOGDIR" |
|
214 |
||
215 |
||
216 |
# run isabelle |
|
217 |
||
7737 | 218 |
PARENT=$(basename "$LOGIC") |
219 |
||
11949 | 220 |
if [ -z "$BUILD" ]; then |
221 |
cd "$NAME" || fail "Bad session directory '$NAME'" |
|
222 |
fi |
|
4451 | 223 |
|
11847 | 224 |
if [ "$DOCUMENT" != false ]; then |
8568 | 225 |
DOC="$DOCUMENT" |
226 |
else |
|
227 |
DOC="" |
|
228 |
fi |
|
7737 | 229 |
|
230 |
||
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
17194
diff
changeset
|
231 |
. "$ISABELLE_HOME/lib/scripts/timestart.bash" |
6249 | 232 |
|
2808 | 233 |
if [ -n "$BUILD" ]; then |
4451 | 234 |
ITEM="$SESSION" |
11577 | 235 |
echo "Building $ITEM ..." >&2 |
4451 | 236 |
LOG="$LOGDIR/$ITEM" |
237 |
||
28502 | 238 |
"$ISABELLE_PROCESS" \ |
31688 | 239 |
-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
|
240 |
-q -w $LOGIC $NAME > "$LOG" |
9788 | 241 |
RC="$?" |
2808 | 242 |
else |
9788 | 243 |
ITEM=$(basename "$LOGIC")-"$SESSION" |
11577 | 244 |
echo "Running $ITEM ..." >&2 |
4451 | 245 |
LOG="$LOGDIR/$ITEM" |
246 |
||
28502 | 247 |
"$ISABELLE_PROCESS" \ |
31688 | 248 |
-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 | 249 |
-r -q "$LOGIC" > "$LOG" |
9788 | 250 |
RC="$?" |
6212 | 251 |
cd .. |
2808 | 252 |
fi |
4451 | 253 |
|
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
17194
diff
changeset
|
254 |
. "$ISABELLE_HOME/lib/scripts/timestop.bash" |
4451 | 255 |
|
256 |
||
257 |
# exit status |
|
258 |
||
9788 | 259 |
if [ "$RC" -eq 0 ]; then |
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
17194
diff
changeset
|
260 |
echo "Finished $ITEM ($TIMES_REPORT)" >&2 |
4451 | 261 |
gzip --force "$LOG" |
262 |
else |
|
11577 | 263 |
{ echo "$ITEM FAILED"; |
264 |
echo "(see also $LOG)"; |
|
32931
540e674ff184
accomodate old version of "tail", e.g. on sunbroy2;
wenzelm
parents:
32641
diff
changeset
|
265 |
echo; tail -20 "$LOG"; echo; } >&2 |
4451 | 266 |
fi |
267 |
||
9788 | 268 |
exit "$RC" |