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