author | wenzelm |
Fri, 11 Sep 2015 14:53:05 +0200 | |
changeset 61159 | da900891ee06 |
parent 59344 | e0ce214303c1 |
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 |
||
40544 | 12 |
function fail() |
13 |
{ |
|
14 |
echo "$1" >&2 |
|
15 |
exit 2 |
|
16 |
} |
|
17 |
||
2349 | 18 |
function fail_out() |
2302 | 19 |
{ |
40544 | 20 |
fail "Unable to create output heap file: \"$OUTFILE\"" |
2302 | 21 |
} |
22 |
||
5063 | 23 |
function check_mlhome_file() |
24 |
{ |
|
40544 | 25 |
[ ! -f "$1" ] && fail "Unable to locate \"$1\"" |
5063 | 26 |
} |
27 |
||
6078 | 28 |
function check_heap_file() |
29 |
{ |
|
30 |
if [ ! -f "$1" ]; then |
|
31 |
echo "Expected to find ML heap file $1" >&2 |
|
32 |
return 1 |
|
33 |
else |
|
34 |
return 0 |
|
35 |
fi |
|
36 |
} |
|
37 |
||
38 |
||
5063 | 39 |
|
40 |
## compiler binaries |
|
41 |
||
40544 | 42 |
[ -z "$ML_HOME" ] && fail "Missing ML installation (ML_HOME)" |
43 |
||
5063 | 44 |
SML="$ML_HOME/sml" |
45 |
ARCH_N_OPSYS="$ML_HOME/.arch-n-opsys" |
|
46 |
||
47 |
check_mlhome_file "$SML" |
|
48 |
check_mlhome_file "$ARCH_N_OPSYS" |
|
49 |
||
53657
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
wenzelm
parents:
48662
diff
changeset
|
50 |
eval $("$ARCH_N_OPSYS") |
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
wenzelm
parents:
48662
diff
changeset
|
51 |
|
5063 | 52 |
|
2302 | 53 |
|
3046 | 54 |
## prepare databases |
55 |
||
4505 | 56 |
if [ -z "$INFILE" ]; then |
56627 | 57 |
EXIT="fun exit rc = Posix.Process.exit (Word8.fromInt rc);" |
4505 | 58 |
DB="" |
59 |
else |
|
60 |
EXIT="" |
|
3046 | 61 |
DB="@SMLload=$INFILE" |
2349 | 62 |
fi |
63 |
||
4505 | 64 |
if [ -z "$OUTFILE" ]; then |
39619 | 65 |
MLEXIT="" |
4505 | 66 |
else |
53657
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
wenzelm
parents:
48662
diff
changeset
|
67 |
if [ -z "$INFILE" ]; then |
59344
e0ce214303c1
proper Session.save with shutdown, which is relevant to avoid persistent threads;
wenzelm
parents:
56627
diff
changeset
|
68 |
MLEXIT="if SMLofNJ.exportML \"$OUTFILE\" then () else OS.FileSys.rename {old = \"$OUTFILE.$ARCH-$OPSYS\", new = \"$OUTFILE\"};" |
53657
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
wenzelm
parents:
48662
diff
changeset
|
69 |
else |
59344
e0ce214303c1
proper Session.save with shutdown, which is relevant to avoid persistent threads;
wenzelm
parents:
56627
diff
changeset
|
70 |
MLEXIT="Session.save \"$OUTFILE\";" |
53657
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
wenzelm
parents:
48662
diff
changeset
|
71 |
fi |
4505 | 72 |
[ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
73 |
fi |
|
2302 | 74 |
|
75 |
||
76 |
## run it! |
|
77 |
||
59344
e0ce214303c1
proper Session.save with shutdown, which is relevant to avoid persistent threads;
wenzelm
parents:
56627
diff
changeset
|
78 |
MLTEXT="$EXIT $MLTEXT" |
2302 | 79 |
|
4505 | 80 |
if [ -z "$TERMINATE" ]; then |
81 |
FEEDER_OPTS="" |
|
2302 | 82 |
else |
4505 | 83 |
FEEDER_OPTS="-q" |
2302 | 84 |
fi |
85 |
||
9789 | 86 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \ |
48002
6de952f4069f
potentially more convincing kill -TERM of feeder (cf. 32c03d45fffe) -- attempt to workaround spurious perl "hangs" on lxbroy10;
wenzelm
parents:
40544
diff
changeset
|
87 |
{ read FPID; "$SML" $ML_OPTIONS "$DB"; RC="$?"; kill -TERM "$FPID"; exit "$RC"; } |
9789 | 88 |
RC="$?" |
4505 | 89 |
|
90 |
||
91 |
## fix heap file name and permissions |
|
3046 | 92 |
|
4505 | 93 |
if [ -n "$OUTFILE" ]; then |
53657
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
wenzelm
parents:
48662
diff
changeset
|
94 |
check_heap_file "$OUTFILE" && [ -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
4505 | 95 |
fi |
3503 | 96 |
|
9789 | 97 |
exit "$RC" |