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