author | kleing |
Wed, 05 Dec 2007 04:29:27 +0100 | |
changeset 25530 | a09ab5a79d42 |
parent 25446 | c1be3072ea8f |
permissions | -rwxr-xr-x |
23943 | 1 |
#!/usr/bin/env bash |
2 |
# |
|
3 |
# $Id$ |
|
4 |
# Author: Makarius |
|
5 |
# |
|
6 |
# Poly/ML startup script (for 5.1) |
|
7 |
||
8 |
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE |
|
9 |
||
10 |
||
11 |
## diagnostics |
|
12 |
||
13 |
function fail_out() |
|
14 |
{ |
|
15 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
|
16 |
exit 2 |
|
17 |
} |
|
18 |
||
19 |
function check_file() |
|
20 |
{ |
|
21 |
if [ ! -f "$1" ]; then |
|
22 |
echo "Unable to locate $1" >&2 |
|
23 |
echo "Please check your ML system settings!" >&2 |
|
24 |
exit 2 |
|
25 |
fi |
|
26 |
} |
|
27 |
||
28 |
||
29 |
## compiler executables and libraries |
|
30 |
||
31 |
POLY="$ML_HOME/poly" |
|
32 |
check_file "$POLY" |
|
33 |
||
34 |
if [ "$(basename "$ML_HOME")" = bin ]; then |
|
35 |
POLYLIB="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib; pwd)" |
|
36 |
else |
|
37 |
POLYLIB="$ML_HOME" |
|
38 |
fi |
|
39 |
||
40 |
export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH" |
|
41 |
export DYLD_LIBRARY_PATH="$POLYLIB:$DYLD_LIBRARY_PATH" |
|
42 |
||
43 |
||
44 |
## prepare databases |
|
45 |
||
46 |
if [ -z "$INFILE" ]; then |
|
25276
f9237f6f3a8d
replaced cc/ld phase by PolyML.SaveState.saveState (potentially more efficient);
wenzelm
parents:
24480
diff
changeset
|
47 |
INIT="" |
23943 | 48 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
49 |
else |
|
50 |
check_file "$INFILE" |
|
25446 | 51 |
INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ())); PolyML.SaveState.loadState \"$INFILE\" handle Fail msg => (TextIO.output (TextIO.stdErr, msg ^ \"\\n\"); OS.Process.exit OS.Process.failure));" |
23943 | 52 |
EXIT="" |
53 |
fi |
|
54 |
||
55 |
if [ -z "$OUTFILE" ]; then |
|
56 |
COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);' |
|
57 |
else |
|
58 |
if [ -z "$COMPRESS" ]; then |
|
25276
f9237f6f3a8d
replaced cc/ld phase by PolyML.SaveState.saveState (potentially more efficient);
wenzelm
parents:
24480
diff
changeset
|
59 |
COMMIT="fun commit () = (TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);" |
23943 | 60 |
else |
25276
f9237f6f3a8d
replaced cc/ld phase by PolyML.SaveState.saveState (potentially more efficient);
wenzelm
parents:
24480
diff
changeset
|
61 |
COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);" |
23943 | 62 |
fi |
63 |
[ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
|
64 |
fi |
|
65 |
||
66 |
||
67 |
## run it! |
|
68 |
||
25276
f9237f6f3a8d
replaced cc/ld phase by PolyML.SaveState.saveState (potentially more efficient);
wenzelm
parents:
24480
diff
changeset
|
69 |
MLTEXT="$INIT $EXIT $COMMIT $MLTEXT" |
23943 | 70 |
MLEXIT="commit();" |
71 |
||
72 |
if [ -z "$TERMINATE" ]; then |
|
73 |
FEEDER_OPTS="" |
|
74 |
else |
|
75 |
FEEDER_OPTS="-q" |
|
76 |
fi |
|
77 |
||
25276
f9237f6f3a8d
replaced cc/ld phase by PolyML.SaveState.saveState (potentially more efficient);
wenzelm
parents:
24480
diff
changeset
|
78 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \ |
f9237f6f3a8d
replaced cc/ld phase by PolyML.SaveState.saveState (potentially more efficient);
wenzelm
parents:
24480
diff
changeset
|
79 |
{ read FPID; "$POLY" -q $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
23943 | 80 |
RC="$?" |
81 |
||
25276
f9237f6f3a8d
replaced cc/ld phase by PolyML.SaveState.saveState (potentially more efficient);
wenzelm
parents:
24480
diff
changeset
|
82 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
23943 | 83 |
|
84 |
exit "$RC" |