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