author | nipkow |
Sat, 17 Apr 2004 14:51:00 +0200 | |
changeset 14614 | 196ff8d245bf |
parent 12912 | 0e144958cf27 |
child 14981 | e73f8140af78 |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2808 | 2 |
# |
3 |
# $Id$ |
|
9788 | 4 |
# Author: Markus Wenzel, TU Muenchen |
5 |
# License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
2808 | 6 |
# |
7 |
# DESCRIPTION: build object-logic or run examples |
|
8 |
||
9 |
||
10 |
## diagnostics |
|
11 |
||
10511 | 12 |
PRG="$(basename "$0")" |
2808 | 13 |
|
14 |
function usage() |
|
15 |
{ |
|
16 |
echo |
|
9237 | 17 |
echo "Usage: $PRG [OPTIONS] LOGIC NAME" |
2808 | 18 |
echo |
19 |
echo " Options are:" |
|
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
20 |
echo " -D PATH dump generated document sources into PATH" |
6940 | 21 |
echo " -P PATH set path for remote theory browsing information" |
6212 | 22 |
echo " -b build mode (output heap image, using current dir)" |
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
8241
diff
changeset
|
23 |
echo " -c BOOL tell ML system to compress output image (default true)" |
7737 | 24 |
echo " -d FORMAT build document as FORMAT (default false)" |
11847 | 25 |
echo " -g BOOL generate session graph image for document (default false)" |
26 |
echo " -i BOOL generate HTML and graph browser information (default false)" |
|
10562 | 27 |
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
|
28 |
echo " -p LEVEL set level of detail for proof objects" |
6212 | 29 |
echo " -r reset session path" |
2808 | 30 |
echo " -s NAME override session NAME" |
11577 | 31 |
echo " -v BOOL be verbose (default false)" |
2808 | 32 |
echo |
33 |
echo " Build object-logic or run examples. Also creates browsing" |
|
34 |
echo " information (HTML etc.) according to settings." |
|
35 |
echo |
|
7461 | 36 |
echo " ISABELLE_USEDIR_OPTIONS=$ISABELLE_USEDIR_OPTIONS" |
37 |
echo |
|
2808 | 38 |
exit 1 |
39 |
} |
|
40 |
||
11577 | 41 |
function fail() |
42 |
{ |
|
43 |
echo "$1" >&2 |
|
44 |
exit 2 |
|
45 |
} |
|
46 |
||
47 |
function check_bool() |
|
48 |
{ |
|
49 |
[ "$1" = true -o "$1" = false ] || fail "Bad boolean: \"$1\"" |
|
50 |
} |
|
51 |
||
52 |
function check_number() |
|
53 |
{ |
|
12912 | 54 |
[ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\"" |
11577 | 55 |
} |
56 |
||
2808 | 57 |
|
58 |
## process command line |
|
59 |
||
60 |
# options |
|
61 |
||
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
62 |
DUMP="" |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
63 |
RPATH="" |
2808 | 64 |
BUILD="" |
8747 | 65 |
COMPRESS=true |
7737 | 66 |
DOCUMENT=false |
11847 | 67 |
DOCUMENT_GRAPH=false |
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
68 |
INFO=false |
10562 | 69 |
MODES="" |
6212 | 70 |
RESET=false |
2808 | 71 |
SESSION="" |
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11535
diff
changeset
|
72 |
PROOFS=0 |
11577 | 73 |
VERBOSE=false |
2808 | 74 |
|
2917 | 75 |
function getoptions() |
76 |
{ |
|
77 |
OPTIND=1 |
|
11847 | 78 |
while getopts "D:P:bc:d:g:i:m:p:rs:v:" OPT |
2917 | 79 |
do |
80 |
case "$OPT" in |
|
8197
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
81 |
D) |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
82 |
DUMP="$OPTARG" |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
83 |
;; |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
84 |
P) |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
85 |
RPATH="$OPTARG" |
baab8e487fad
-D PATH: dump generated document sources into PATH;
wenzelm
parents:
7888
diff
changeset
|
86 |
;; |
2917 | 87 |
b) |
88 |
BUILD=true |
|
89 |
;; |
|
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
8241
diff
changeset
|
90 |
c) |
11577 | 91 |
check_bool "$OPTARG" |
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
8241
diff
changeset
|
92 |
COMPRESS="$OPTARG" |
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
8241
diff
changeset
|
93 |
;; |
7737 | 94 |
d) |
95 |
DOCUMENT="$OPTARG" |
|
96 |
;; |
|
11847 | 97 |
g) |
98 |
check_bool "$OPTARG" |
|
99 |
DOCUMENT_GRAPH="$OPTARG" |
|
100 |
;; |
|
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
101 |
i) |
11577 | 102 |
check_bool "$OPTARG" |
3747
cd9b6c86926c
There is now one single option -i for generating theory browsing
berghofe
parents:
3636
diff
changeset
|
103 |
INFO="$OPTARG" |
2917 | 104 |
;; |
10562 | 105 |
m) |
106 |
if [ -z "$MODES" ]; then |
|
107 |
MODES="\"$OPTARG\"" |
|
108 |
else |
|
10585 | 109 |
MODES="\"$OPTARG\", $MODES" |
10562 | 110 |
fi |
111 |
;; |
|
11535
7f4c5cdea239
Added new option for setting level of detail for proof objects.
berghofe
parents:
10585
diff
changeset
|
112 |
p) |
11577 | 113 |
check_number "$OPTARG" |
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11535
diff
changeset
|
114 |
PROOFS="$OPTARG" |
11535
7f4c5cdea239
Added new option for setting level of detail for proof objects.
berghofe
parents:
10585
diff
changeset
|
115 |
;; |
6212 | 116 |
r) |
117 |
RESET=true |
|
118 |
;; |
|
2917 | 119 |
s) |
120 |
SESSION="$OPTARG" |
|
121 |
;; |
|
11577 | 122 |
v) |
123 |
check_bool "$OPTARG" |
|
124 |
VERBOSE="$OPTARG" |
|
125 |
;; |
|
2917 | 126 |
\?) |
127 |
usage |
|
128 |
;; |
|
129 |
esac |
|
130 |
done |
|
131 |
} |
|
2808 | 132 |
|
2917 | 133 |
getoptions $ISABELLE_USEDIR_OPTIONS |
134 |
||
135 |
getoptions "$@" |
|
2808 | 136 |
shift $(($OPTIND - 1)) |
137 |
||
138 |
||
139 |
# args |
|
140 |
||
9788 | 141 |
[ "$#" -ne 2 ] && usage |
2808 | 142 |
|
143 |
LOGIC="$1"; shift |
|
144 |
NAME="$1"; shift |
|
145 |
||
9788 | 146 |
[ -z "$SESSION" ] && SESSION=$(basename "$NAME") |
2808 | 147 |
|
4419 | 148 |
|
149 |
||
150 |
## main |
|
3636
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
151 |
|
4451 | 152 |
# prepare browser info dir |
4419 | 153 |
|
9788 | 154 |
if [ "$INFO" = "true" -a ! -f "$ISABELLE_BROWSER_INFO/index.html" ]; then |
155 |
mkdir -p "$ISABELLE_BROWSER_INFO" |
|
156 |
cp "$ISABELLE_HOME/lib/logo/isabelle.gif" "$ISABELLE_BROWSER_INFO/isabelle.gif" |
|
157 |
cp "$ISABELLE_HOME/lib/html/index.html" "$ISABELLE_BROWSER_INFO/index.html" |
|
3636
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
158 |
fi |
3f2e55e5bacc
Added some code for generating theory browsing data.
berghofe
parents:
3504
diff
changeset
|
159 |
|
2808 | 160 |
|
4451 | 161 |
# prepare log dir |
162 |
||
163 |
LOGDIR="$ISABELLE_OUTPUT/log" |
|
164 |
mkdir -p "$LOGDIR" |
|
165 |
||
166 |
||
167 |
# run isabelle |
|
168 |
||
7737 | 169 |
PARENT=$(basename "$LOGIC") |
170 |
||
11949 | 171 |
if [ -z "$BUILD" ]; then |
172 |
cd "$NAME" || fail "Bad session directory '$NAME'" |
|
173 |
fi |
|
4451 | 174 |
|
11847 | 175 |
if [ "$DOCUMENT" != false ]; then |
8568 | 176 |
DOC="$DOCUMENT" |
177 |
else |
|
178 |
DOC="" |
|
179 |
fi |
|
7737 | 180 |
|
181 |
||
182 |
SECONDS=0 |
|
6249 | 183 |
|
2808 | 184 |
if [ -n "$BUILD" ]; then |
4451 | 185 |
ITEM="$SESSION" |
11577 | 186 |
echo "Building $ITEM ..." >&2 |
4451 | 187 |
LOG="$LOGDIR/$ITEM" |
188 |
||
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
8241
diff
changeset
|
189 |
OPT_C="" |
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
8241
diff
changeset
|
190 |
[ "$COMPRESS" = true ] && OPT_C="-c" |
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
8241
diff
changeset
|
191 |
|
9788 | 192 |
"$ISABELLE" \ |
11907 | 193 |
-e "Session.use_dir true [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH \"$PARENT\" \"$SESSION\" \"$DUMP\" \"$RPATH\" $PROOFS $VERBOSE;" \ |
11577 | 194 |
$OPT_C -q -w $LOGIC $NAME > "$LOG" |
9788 | 195 |
RC="$?" |
2808 | 196 |
else |
9788 | 197 |
ITEM=$(basename "$LOGIC")-"$SESSION" |
11577 | 198 |
echo "Running $ITEM ..." >&2 |
4451 | 199 |
LOG="$LOGDIR/$ITEM" |
200 |
||
9788 | 201 |
"$ISABELLE" \ |
11907 | 202 |
-e "Session.use_dir false [$MODES] $RESET $INFO \"$DOC\" $DOCUMENT_GRAPH \"$PARENT\" \"$SESSION\" \"$DUMP\" \"$RPATH\" $PROOFS $VERBOSE; quit();" \ |
11577 | 203 |
-r -q "$LOGIC" > "$LOG" |
9788 | 204 |
RC="$?" |
6212 | 205 |
cd .. |
2808 | 206 |
fi |
4451 | 207 |
|
9788 | 208 |
ELAPSED=$("$ISABELLE_HOME/lib/scripts/showtime" "$SECONDS") |
4451 | 209 |
|
210 |
||
211 |
# exit status |
|
212 |
||
9788 | 213 |
if [ "$RC" -eq 0 ]; then |
11577 | 214 |
echo "Finished $ITEM ($ELAPSED elapsed time)" >&2 |
4451 | 215 |
gzip --force "$LOG" |
216 |
else |
|
11577 | 217 |
{ echo "$ITEM FAILED"; |
218 |
echo "(see also $LOG)"; |
|
219 |
echo; tail "$LOG"; echo; } >&2 |
|
4451 | 220 |
fi |
221 |
||
9788 | 222 |
exit "$RC" |