author | wenzelm |
Tue, 14 Jun 2005 22:08:53 +0200 | |
changeset 16392 | 7212040b71f2 |
parent 16374 | f4b7cf8975af |
child 16393 | 4bc08baa3fbb |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2301 | 2 |
# |
2314 | 3 |
# $Id$ |
9789 | 4 |
# Author: Markus Wenzel, TU Muenchen |
2314 | 5 |
# |
2301 | 6 |
# Poly/ML startup script. |
9977 | 7 |
|
10105 | 8 |
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE |
2301 | 9 |
|
10 |
||
11 |
## diagnostics |
|
12 |
||
2349 | 13 |
function fail_out() |
2301 | 14 |
{ |
2349 | 15 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
2301 | 16 |
exit 2 |
17 |
} |
|
18 |
||
10206 | 19 |
function check_file() |
5063 | 20 |
{ |
21 |
if [ ! -f "$1" ]; then |
|
22 |
echo "Unable to locate $1" >&2 |
|
10206 | 23 |
echo "Please check your ML system settings!" >&2 |
5063 | 24 |
exit 2 |
25 |
fi |
|
26 |
} |
|
27 |
||
2301 | 28 |
|
16392 | 29 |
## Poly/ML executable and database |
2301 | 30 |
|
10206 | 31 |
ML_DBASE_PREFIX="" |
16374 | 32 |
ML_DBASE_SUFFIX="" |
33 |
||
34 |
case "$ML_PLATFORM" in |
|
35 |
*-cygwin) |
|
36 |
ML_DBASE_SUFFIX=".pmd" |
|
37 |
POLY="$ML_HOME/PolyML.exe" |
|
16392 | 38 |
function fixpath () { cygpath -m "$@"; } |
16374 | 39 |
;; |
40 |
*) |
|
41 |
POLY="$ML_HOME/poly" |
|
16392 | 42 |
function fixpath () { echo -n "$@"; } |
16374 | 43 |
;; |
44 |
esac |
|
45 |
||
10206 | 46 |
check_file "$POLY" |
2301 | 47 |
|
16392 | 48 |
if [ -z "$ML_DBASE" ]; then |
49 |
if [ -z "$COPYDB" ]; then |
|
50 |
ML_DBASE_PREFIX="$ML_HOME/" |
|
51 |
ML_DBASE="ML_dbase${ML_DBASE_SUFFIX}" |
|
52 |
else |
|
53 |
ML_DBASE="$ML_HOME/ML_dbase${ML_DBASE_SUFFIX}" |
|
54 |
fi |
|
55 |
export POLYPATH="$(fixpath "$ML_HOME")" |
|
56 |
else |
|
57 |
export POLYPATH="$(fixpath "$(dirname "$ML_DBASE")")" |
|
58 |
fi |
|
10206 | 59 |
|
16392 | 60 |
DISCGARB="$POLY" |
61 |
DISCGARB_OPTIONS="-d -c" |
|
10206 | 62 |
|
16392 | 63 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
9765 | 64 |
|
65 |
||
2301 | 66 |
## prepare databases |
67 |
||
68 |
if [ -z "$INFILE" ]; then |
|
10206 | 69 |
check_file "$ML_DBASE_PREFIX$ML_DBASE" |
70 |
INFILE="$ML_DBASE" |
|
9765 | 71 |
MLTEXT="val use = PolyML.use; $EXIT $MLTEXT" |
16285 | 72 |
case "$ML_SYSTEM" in |
73 |
polyml-4.1.[12]) |
|
74 |
DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S 180" |
|
75 |
;; |
|
76 |
polyml-4.1.*) |
|
77 |
DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S max" |
|
78 |
;; |
|
79 |
esac |
|
10105 | 80 |
else |
81 |
COPYDB=true |
|
2301 | 82 |
fi |
83 |
||
84 |
if [ -z "$OUTFILE" ]; then |
|
85 |
DB="$INFILE" |
|
15850
30e878979457
no longer need feeder to run normal interactive sessions;
wenzelm
parents:
14981
diff
changeset
|
86 |
ML_OPTIONS="-r $ML_OPTIONS" |
2349 | 87 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
2301 | 88 |
DB="$INFILE" |
89 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
90 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 91 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 92 |
chmod +w "$OUTFILE" || fail_out |
2301 | 93 |
DB="$OUTFILE" |
94 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
95 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
16392 | 96 |
echo "PolyML.make_database \"$(fixpath "$OUTFILE")\"; PolyML.quit();" | "$POLY" -r "$(fixpath "$INFILE")" |
2301 | 97 |
[ -f "$OUTFILE" ] || fail_out |
98 |
DB="$OUTFILE" |
|
99 |
fi |
|
100 |
||
101 |
||
102 |
## run it! |
|
103 |
||
16254
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
104 |
if [ -z "$TERMINATE" ]; then |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
105 |
FEEDER_OPTS="" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
106 |
else |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
107 |
FEEDER_OPTS="-q" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
108 |
fi |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
109 |
|
16392 | 110 |
DB_INFO="$(ls -l "$DB" 2>/dev/null)" |
15850
30e878979457
no longer need feeder to run normal interactive sessions;
wenzelm
parents:
14981
diff
changeset
|
111 |
|
16392 | 112 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | { |
113 |
read FPID; "$POLY" $ML_OPTIONS "$(fixpath "$DB")"; |
|
114 |
RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
|
9789 | 115 |
RC="$?" |
2301 | 116 |
|
16392 | 117 |
NEW_DB_INFO="$(ls -l "$DB" 2>/dev/null)" |
10206 | 118 |
[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \ |
119 |
"$DISCGARB" $DISCGARB_OPTIONS "$OUTFILE" |
|
4505 | 120 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 121 |
|
9789 | 122 |
exit "$RC" |