author | wenzelm |
Sun, 04 Feb 2001 22:34:52 +0100 | |
changeset 11060 | a58e0bd448df |
parent 10905 | e23abeef8150 |
child 11550 | 915c5de6480f |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2292 | 2 |
# |
2308 | 3 |
# $Id$ |
9786 | 4 |
# Author: Markus Wenzel, TU Muenchen |
5 |
# License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
2308 | 6 |
# |
2292 | 7 |
# Basic Isabelle startup script. |
8 |
||
9 |
||
10 |
## settings |
|
11 |
||
10511 | 12 |
PRG="$(basename "$0")" |
2704 | 13 |
|
10511 | 14 |
ISABELLE_HOME="$(dirname "$0")/.." |
9786 | 15 |
. "$ISABELLE_HOME/lib/scripts/getsettings" || \ |
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2768
diff
changeset
|
16 |
{ echo "$PRG probably not called from its original place!"; exit 2; } |
2292 | 17 |
|
18 |
||
19 |
## diagnostics |
|
20 |
||
21 |
function usage() |
|
22 |
{ |
|
23 |
echo |
|
24 |
echo "Usage: $PRG [OPTIONS] [INPUT] [OUTPUT]" |
|
25 |
echo |
|
26 |
echo " Options are:" |
|
10104 | 27 |
echo " -C tell ML system to copy output image" |
5815 | 28 |
echo " -I startup Isar interaction mode" |
9982 | 29 |
echo " -P startup Proof General interaction mode" |
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
30 |
echo " -c tell ML system to compress output image" |
2343 | 31 |
echo " -e MLTEXT pass MLTEXT to the ML session" |
10905 | 32 |
echo " -f pass 'Session.finish();' to the ML session" |
2704 | 33 |
echo " -m MODE add print mode for output" |
2292 | 34 |
echo " -q non-interactive session" |
35 |
echo " -r open heap file read-only" |
|
4516 | 36 |
echo " -u pass 'use\"ROOT.ML\";' to the ML session" |
3502 | 37 |
echo " -w reset write permissions on OUTPUT" |
2292 | 38 |
echo |
3184 | 39 |
echo " INPUT (default \"$ISABELLE_LOGIC\") and OUTPUT specify in/out heaps." |
7887 | 40 |
echo " These are either names to be searched in the Isabelle path, or" |
41 |
echo " actual file names (containing at least one /)." |
|
2768 | 42 |
echo " If INPUT is \"RAW_ML_SYSTEM\", just start the bare bones ML system." |
2292 | 43 |
echo |
44 |
exit 1 |
|
45 |
} |
|
46 |
||
47 |
function fail() |
|
48 |
{ |
|
2343 | 49 |
echo "$1" >&2 |
2292 | 50 |
exit 2 |
51 |
} |
|
52 |
||
53 |
||
54 |
## process command line |
|
55 |
||
56 |
# options |
|
57 |
||
10104 | 58 |
COPYDB="" |
9972 | 59 |
ISAR=false |
60 |
PROOFGENERAL="" |
|
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
61 |
COMPRESS="" |
2292 | 62 |
MLTEXT="" |
2704 | 63 |
MODES="" |
2292 | 64 |
TERMINATE="" |
65 |
READONLY="" |
|
3502 | 66 |
NOWRITE="" |
2292 | 67 |
|
10905 | 68 |
while getopts "CIPce:fm:qruw" OPT |
2292 | 69 |
do |
70 |
case "$OPT" in |
|
10104 | 71 |
C) |
72 |
COPYDB=true |
|
73 |
;; |
|
5815 | 74 |
I) |
9972 | 75 |
ISAR=true |
76 |
;; |
|
77 |
P) |
|
78 |
PROOFGENERAL=true |
|
5815 | 79 |
;; |
8359
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
80 |
c) |
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
81 |
COMPRESS=true |
124ad46105dd
option -c: tell ML system to compress output image;
wenzelm
parents:
7887
diff
changeset
|
82 |
;; |
2292 | 83 |
e) |
84 |
MLTEXT="$MLTEXT $OPTARG" |
|
85 |
;; |
|
10905 | 86 |
f) |
87 |
MLTEXT="$MLTEXT Session.finish();" |
|
88 |
;; |
|
2704 | 89 |
m) |
90 |
if [ -z "$MODES" ]; then |
|
91 |
MODES="\"$OPTARG\"" |
|
92 |
else |
|
10585 | 93 |
MODES="\"$OPTARG\", $MODES" |
2704 | 94 |
fi |
95 |
;; |
|
2292 | 96 |
q) |
97 |
TERMINATE=true |
|
98 |
;; |
|
99 |
r) |
|
100 |
READONLY=true |
|
101 |
;; |
|
4516 | 102 |
u) |
103 |
MLTEXT="$MLTEXT use\"ROOT.ML\";" |
|
104 |
;; |
|
3502 | 105 |
w) |
106 |
NOWRITE=true |
|
107 |
;; |
|
2292 | 108 |
\?) |
109 |
usage |
|
110 |
;; |
|
111 |
esac |
|
112 |
done |
|
113 |
||
114 |
shift $(($OPTIND - 1)) |
|
115 |
||
116 |
||
117 |
# args |
|
118 |
||
119 |
INPUT="" |
|
120 |
OUTPUT="" |
|
121 |
||
9786 | 122 |
if [ "$#" -ge 1 ]; then |
2292 | 123 |
INPUT="$1" |
124 |
shift |
|
125 |
fi |
|
126 |
||
9786 | 127 |
if [ "$#" -ge 1 ]; then |
2292 | 128 |
OUTPUT="$1" |
129 |
shift |
|
130 |
fi |
|
131 |
||
9786 | 132 |
[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; } |
2292 | 133 |
|
134 |
||
135 |
## check ML system |
|
136 |
||
2308 | 137 |
[ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle." |
2292 | 138 |
|
139 |
||
140 |
## input heap file |
|
141 |
||
3184 | 142 |
[ -z "$INPUT" ] && INPUT="$ISABELLE_LOGIC" |
2292 | 143 |
|
144 |
case "$INPUT" in |
|
2768 | 145 |
RAW_ML_SYSTEM) |
2292 | 146 |
INFILE="" |
147 |
;; |
|
148 |
*/*) |
|
149 |
INFILE="$INPUT" |
|
2343 | 150 |
[ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\"" |
2292 | 151 |
;; |
152 |
*) |
|
9786 | 153 |
INFILE="" |
2308 | 154 |
ISA_PATH="" |
9786 | 155 |
|
156 |
ORIG_IFS="$IFS" |
|
157 |
IFS=":" |
|
158 |
for DIR in $ISABELLE_PATH |
|
2292 | 159 |
do |
9786 | 160 |
DIR="$DIR/$ML_IDENTIFIER" |
161 |
ISA_PATH="$ISA_PATH $DIR\n" |
|
162 |
[ -z "$INFILE" -a -f "$DIR/$INPUT" ] && INFILE="$DIR/$INPUT" |
|
2292 | 163 |
done |
9786 | 164 |
IFS="$ORIG_IFS" |
165 |
||
2308 | 166 |
if [ -z "$INFILE" ]; then |
2343 | 167 |
echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2 |
9786 | 168 |
echo -ne "$ISA_PATH" >&2 |
2308 | 169 |
exit 2 |
170 |
fi |
|
2292 | 171 |
;; |
172 |
esac |
|
173 |
||
174 |
||
175 |
## output heap file |
|
176 |
||
177 |
case "$OUTPUT" in |
|
178 |
"") |
|
179 |
[ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE" |
|
180 |
;; |
|
181 |
*/*) |
|
182 |
OUTFILE="$OUTPUT" |
|
183 |
;; |
|
184 |
*) |
|
3118 | 185 |
mkdir -p "$ISABELLE_OUTPUT" |
186 |
OUTFILE="$ISABELLE_OUTPUT/$OUTPUT" |
|
2292 | 187 |
;; |
188 |
esac |
|
189 |
||
190 |
||
4333 | 191 |
## prepare tmp directory |
192 |
||
193 |
[ -z "$ISABELLE_TMP_PREFIX" ] && ISABELLE_TMP_PREFIX=/tmp/isabelle |
|
194 |
||
195 |
ISABELLE_TMP="$ISABELLE_TMP_PREFIX$$" |
|
196 |
mkdir -p "$ISABELLE_TMP" |
|
197 |
||
198 |
||
2292 | 199 |
## run it! |
200 |
||
9786 | 201 |
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-) |
2292 | 202 |
|
2704 | 203 |
[ -n "$MODES" ] && MLTEXT="print_mode := [$MODES]; $MLTEXT" |
204 |
||
9972 | 205 |
if [ -n "$PROOFGENERAL" ]; then |
206 |
MLTEXT="$MLTEXT; ProofGeneral.init $ISAR;" |
|
207 |
elif [ "$ISAR" = true ]; then |
|
208 |
MLTEXT="$MLTEXT; Isar.main();" |
|
209 |
fi |
|
210 |
||
10104 | 211 |
export INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE ISABELLE_TMP |
4333 | 212 |
|
9786 | 213 |
if [ -f "$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM" ]; then |
214 |
"$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM" |
|
4333 | 215 |
else |
9786 | 216 |
"$ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE" |
4333 | 217 |
fi |
9786 | 218 |
RC="$?" |
4333 | 219 |
|
220 |
#Do not even think of 'rm -r'!! |
|
9786 | 221 |
rmdir "$ISABELLE_TMP" |
4355 | 222 |
|
9786 | 223 |
exit "$RC" |