author | wenzelm |
Sun, 31 May 2009 15:49:35 +0200 | |
changeset 31317 | 1f5740424c69 |
parent 31307 | 7015fee8c3e8 |
child 31688 | f27cc190083b |
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" |
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
|
22 |
echo " -Q BOOL check proofs in parallel (default true)" |
24118 | 23 |
echo " -T LEVEL multithreading: trace level (default 0)" |
17050 | 24 |
echo " -V VERSION declare alternative document VERSION" |
6212 | 25 |
echo " -b build mode (output heap image, using current dir)" |
7737 | 26 |
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
|
27 |
echo " -f NAME use ML file NAME (default ROOT.ML)" |
11847 | 28 |
echo " -g BOOL generate session graph image for document (default false)" |
29 |
echo " -i BOOL generate HTML and graph browser information (default false)" |
|
10562 | 30 |
echo " -m MODE add print mode for output" |
11535
7f4c5cdea239
Added new option for setting level of detail for proof objects.
berghofe
parents:
10585
diff
changeset
|
31 |
echo " -p LEVEL set level of detail for proof objects" |
6212 | 32 |
echo " -r reset session path" |
2808 | 33 |
echo " -s NAME override session NAME" |
11577 | 34 |
echo " -v BOOL be verbose (default false)" |
2808 | 35 |
echo |
36 |
echo " Build object-logic or run examples. Also creates browsing" |
|
37 |
echo " information (HTML etc.) according to settings." |
|
38 |
echo |
|
7461 | 39 |
echo " ISABELLE_USEDIR_OPTIONS=$ISABELLE_USEDIR_OPTIONS" |
24957 | 40 |
echo " HOL_USEDIR_OPTIONS=$HOL_USEDIR_OPTIONS" |
7461 | 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="" |
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
|
75 |
PARALLEL_PROOFS="true" |
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="" |
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11535
diff
changeset
|
86 |
PROOFS=0 |
11577 | 87 |
VERBOSE=false |
2808 | 88 |
|
2917 | 89 |
function getoptions() |
90 |
{ |
|
91 |
OPTIND=1 |
|
31317
1f5740424c69
removed "compress" option from isabelle-process and isabelle usedir -- this is always enabled;
wenzelm
parents:
31307
diff
changeset
|
92 |
while getopts "C:D:M:P:Q:T:V:bd:f:g:i:m:p:rs:v:" OPT |
2917 | 93 |
do |
94 |
case "$OPT" in |
|
17194
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
95 |
C) |
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
96 |
check_bool "$OPTARG" |
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
97 |
COPY_DUMP="$OPTARG" |
70d96933c210
added option -C: copy existing document directory;
wenzelm
parents:
17050
diff
changeset
|
98 |
;; |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
99 |
D) |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
100 |
DUMP="$OPTARG" |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
101 |
;; |
23972 | 102 |
M) |
25774 | 103 |
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
|
104 |
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
|
105 |
else |
25774 | 106 |
check_number "$OPTARG" |
107 |
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
|
108 |
fi |
23972 | 109 |
;; |
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
110 |
P) |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
111 |
RPATH="$OPTARG" |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
112 |
;; |
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
|
113 |
Q) |
a5f84ac14609
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents:
29143
diff
changeset
|
114 |
PARALLEL_PROOFS="$OPTARG" |
a5f84ac14609
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents:
29143
diff
changeset
|
115 |
;; |
24061 | 116 |
T) |
24118 | 117 |
check_number "$OPTARG" |
24061 | 118 |
TRACETHREADS="$OPTARG" |
119 |
;; |
|
17050 | 120 |
V) |
121 |
if [ -z "$DOCUMENT_VERSIONS" ]; then |
|
122 |
DOCUMENT_VERSIONS="\"$OPTARG\"" |
|
123 |
else |
|
124 |
DOCUMENT_VERSIONS="$DOCUMENT_VERSIONS, \"$OPTARG\"" |
|
125 |
fi |
|
126 |
;; |
|
2917 | 127 |
b) |
128 |
BUILD=true |
|
129 |
;; |
|
7737 | 130 |
d) |
131 |
DOCUMENT="$OPTARG" |
|
132 |
;; |
|
15269
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
133 |
f) |
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
134 |
ROOT_FILE="$OPTARG" |
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
135 |
;; |
11847 | 136 |
g) |
137 |
check_bool "$OPTARG" |
|
138 |
DOCUMENT_GRAPH="$OPTARG" |
|
139 |
;; |
|
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
140 |
i) |
11577 | 141 |
check_bool "$OPTARG" |
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
142 |
INFO="$OPTARG" |
2917 | 143 |
;; |
10562 | 144 |
m) |
145 |
if [ -z "$MODES" ]; then |
|
146 |
MODES="\"$OPTARG\"" |
|
147 |
else |
|
10585 | 148 |
MODES="\"$OPTARG\", $MODES" |
10562 | 149 |
fi |
150 |
;; |
|
11535
7f4c5cdea239
Added new option for setting level of detail for proof objects.
berghofe
parents:
10585
diff
changeset
|
151 |
p) |
11577 | 152 |
check_number "$OPTARG" |
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11535
diff
changeset
|
153 |
PROOFS="$OPTARG" |
11535
7f4c5cdea239
Added new option for setting level of detail for proof objects.
berghofe
parents:
10585
diff
changeset
|
154 |
;; |
6212 | 155 |
r) |
156 |
RESET=true |
|
157 |
;; |
|
2917 | 158 |
s) |
159 |
SESSION="$OPTARG" |
|
160 |
;; |
|
11577 | 161 |
v) |
162 |
check_bool "$OPTARG" |
|
163 |
VERBOSE="$OPTARG" |
|
164 |
;; |
|
2917 | 165 |
\?) |
166 |
usage |
|
167 |
;; |
|
168 |
esac |
|
169 |
done |
|
170 |
} |
|
2808 | 171 |
|
31307
7015fee8c3e8
ISABELLE_USEDIR_OPTIONS: proper word splitting of quoted options (via array variable and special expansion, cf. "$@");
wenzelm
parents:
29435
diff
changeset
|
172 |
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
|
173 |
getoptions "${OPTIONS[@]}" |
2917 | 174 |
|
175 |
getoptions "$@" |
|
2808 | 176 |
shift $(($OPTIND - 1)) |
177 |
||
178 |
||
179 |
# args |
|
180 |
||
9788 | 181 |
[ "$#" -ne 2 ] && usage |
2808 | 182 |
|
183 |
LOGIC="$1"; shift |
|
184 |
NAME="$1"; shift |
|
185 |
||
9788 | 186 |
[ -z "$SESSION" ] && SESSION=$(basename "$NAME") |
2808 | 187 |
|
4419 | 188 |
|
189 |
||
190 |
## main |
|
3636
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
191 |
|
4451 | 192 |
# prepare browser info dir |
4419 | 193 |
|
25235 | 194 |
if [ "$INFO" = "true" -a ! -f "$ISABELLE_BROWSER_INFO/index.html" ]; then |
9788 | 195 |
mkdir -p "$ISABELLE_BROWSER_INFO" |
196 |
cp "$ISABELLE_HOME/lib/logo/isabelle.gif" "$ISABELLE_BROWSER_INFO/isabelle.gif" |
|
25234 | 197 |
cat "$ISABELLE_HOME/lib/html/library_index_header.template" \ |
198 |
"$ISABELLE_HOME/lib/html/library_index_content.template" \ |
|
199 |
"$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
|
200 |
fi |
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
201 |
|
2808 | 202 |
|
4451 | 203 |
# prepare log dir |
204 |
||
205 |
LOGDIR="$ISABELLE_OUTPUT/log" |
|
206 |
mkdir -p "$LOGDIR" |
|
207 |
||
208 |
||
209 |
# run isabelle |
|
210 |
||
7737 | 211 |
PARENT=$(basename "$LOGIC") |
212 |
||
11949 | 213 |
if [ -z "$BUILD" ]; then |
214 |
cd "$NAME" || fail "Bad session directory '$NAME'" |
|
215 |
fi |
|
4451 | 216 |
|
11847 | 217 |
if [ "$DOCUMENT" != false ]; then |
8568 | 218 |
DOC="$DOCUMENT" |
219 |
else |
|
220 |
DOC="" |
|
221 |
fi |
|
7737 | 222 |
|
223 |
||
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
17194
diff
changeset
|
224 |
. "$ISABELLE_HOME/lib/scripts/timestart.bash" |
6249 | 225 |
|
2808 | 226 |
if [ -n "$BUILD" ]; then |
4451 | 227 |
ITEM="$SESSION" |
11577 | 228 |
echo "Building $ITEM ..." >&2 |
4451 | 229 |
LOG="$LOGDIR/$ITEM" |
230 |
||
28502 | 231 |
"$ISABELLE_PROCESS" \ |
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
|
232 |
-e "Session.use_dir \"$ROOT_FILE\" true [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH [$DOCUMENT_VERSIONS] \"$PARENT\" \"$SESSION\" ($COPY_DUMP, \"$DUMP\") \"$RPATH\" $PROOFS $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
|
233 |
-q -w $LOGIC $NAME > "$LOG" |
9788 | 234 |
RC="$?" |
2808 | 235 |
else |
9788 | 236 |
ITEM=$(basename "$LOGIC")-"$SESSION" |
11577 | 237 |
echo "Running $ITEM ..." >&2 |
4451 | 238 |
LOG="$LOGDIR/$ITEM" |
239 |
||
28502 | 240 |
"$ISABELLE_PROCESS" \ |
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
|
241 |
-e "Session.use_dir \"$ROOT_FILE\" false [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH [$DOCUMENT_VERSIONS] \"$PARENT\" \"$SESSION\" ($COPY_DUMP, \"$DUMP\") \"$RPATH\" $PROOFS $VERBOSE $MAXTHREADS $TRACETHREADS $PARALLEL_PROOFS; quit();" \ |
11577 | 242 |
-r -q "$LOGIC" > "$LOG" |
9788 | 243 |
RC="$?" |
6212 | 244 |
cd .. |
2808 | 245 |
fi |
4451 | 246 |
|
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
17194
diff
changeset
|
247 |
. "$ISABELLE_HOME/lib/scripts/timestop.bash" |
4451 | 248 |
|
249 |
||
250 |
# exit status |
|
251 |
||
9788 | 252 |
if [ "$RC" -eq 0 ]; then |
18321
3414557c2dda
replaced lib/scripts/showtime by more advanced lib/scripts/timestart|stop.bash;
wenzelm
parents:
17194
diff
changeset
|
253 |
echo "Finished $ITEM ($TIMES_REPORT)" >&2 |
4451 | 254 |
gzip --force "$LOG" |
255 |
else |
|
11577 | 256 |
{ echo "$ITEM FAILED"; |
257 |
echo "(see also $LOG)"; |
|
258 |
echo; tail "$LOG"; echo; } >&2 |
|
4451 | 259 |
fi |
260 |
||
9788 | 261 |
exit "$RC" |