author | wenzelm |
Sun, 31 May 2009 15:49:35 +0200 | |
changeset 31317 | 1f5740424c69 |
parent 31315 | 3c7b40548a84 |
child 39619 | 34952c2423c6 |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2302 | 2 |
# |
9789 | 3 |
# Author: Markus Wenzel, TU Muenchen |
2313 | 4 |
# |
5708 | 5 |
# SML/NJ startup script (for 110 or later). |
9977 | 6 |
|
31317
1f5740424c69
removed "compress" option from isabelle-process and isabelle usedir -- this is always enabled;
wenzelm
parents:
31315
diff
changeset
|
7 |
export -n INFILE OUTFILE MLTEXT TERMINATE NOWRITE |
2302 | 8 |
|
9 |
||
10 |
## diagnostics |
|
11 |
||
2349 | 12 |
function fail_out() |
2302 | 13 |
{ |
2349 | 14 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
2302 | 15 |
exit 2 |
16 |
} |
|
17 |
||
5063 | 18 |
function check_mlhome_file() |
19 |
{ |
|
20 |
if [ ! -f "$1" ]; then |
|
21 |
echo "Unable to locate $1" >&2 |
|
22 |
echo "Please check your ML_HOME setting!" >&2 |
|
23 |
exit 2 |
|
24 |
fi |
|
25 |
} |
|
26 |
||
6078 | 27 |
function check_heap_file() |
28 |
{ |
|
29 |
if [ ! -f "$1" ]; then |
|
30 |
echo "Expected to find ML heap file $1" >&2 |
|
31 |
return 1 |
|
32 |
else |
|
33 |
return 0 |
|
34 |
fi |
|
35 |
} |
|
36 |
||
37 |
||
5063 | 38 |
|
39 |
## compiler binaries |
|
40 |
||
41 |
SML="$ML_HOME/sml" |
|
42 |
ARCH_N_OPSYS="$ML_HOME/.arch-n-opsys" |
|
43 |
||
44 |
check_mlhome_file "$SML" |
|
45 |
check_mlhome_file "$ARCH_N_OPSYS" |
|
46 |
||
47 |
||
2302 | 48 |
|
3046 | 49 |
## prepare databases |
50 |
||
4505 | 51 |
if [ -z "$INFILE" ]; then |
52 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
|
53 |
DB="" |
|
54 |
else |
|
55 |
EXIT="" |
|
3046 | 56 |
DB="@SMLload=$INFILE" |
2349 | 57 |
fi |
58 |
||
4505 | 59 |
if [ -z "$OUTFILE" ]; then |
60 |
COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);' |
|
61 |
else |
|
62 |
COMMIT="fun commit () = not (SMLofNJ.exportML\"$OUTFILE\");" |
|
63 |
[ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
|
64 |
fi |
|
2302 | 65 |
|
66 |
||
67 |
## run it! |
|
68 |
||
4505 | 69 |
MLTEXT="$EXIT $COMMIT $MLTEXT" |
70 |
MLEXIT="commit();" |
|
2302 | 71 |
|
4505 | 72 |
if [ -z "$TERMINATE" ]; then |
73 |
FEEDER_OPTS="" |
|
2302 | 74 |
else |
4505 | 75 |
FEEDER_OPTS="-q" |
2302 | 76 |
fi |
77 |
||
9789 | 78 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \ |
79 |
{ read FPID; "$SML" $ML_OPTIONS "$DB"; RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
|
80 |
RC="$?" |
|
4505 | 81 |
|
82 |
||
83 |
## fix heap file name and permissions |
|
3046 | 84 |
|
4505 | 85 |
if [ -n "$OUTFILE" ]; then |
9789 | 86 |
eval $("$ARCH_N_OPSYS") |
6078 | 87 |
[ -z "$HEAP_SUFFIX" ] && HEAP_SUFFIX="$ARCH-$OPSYS" |
88 |
HEAP="$OUTFILE.$HEAP_SUFFIX" |
|
89 |
check_heap_file "$HEAP" && mv "$HEAP" "$OUTFILE" && \ |
|
4505 | 90 |
[ -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
91 |
fi |
|
3503 | 92 |
|
9789 | 93 |
exit "$RC" |