author | blanchet |
Thu, 22 Aug 2013 12:12:51 +0200 | |
changeset 53139 | 07a6e11f1631 |
parent 52831 | 72bbdc64d0de |
child 53657 | 64942a1f7187 |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2301 | 2 |
# |
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
3 |
# Author: Makarius |
2314 | 4 |
# |
52831 | 5 |
# Startup script for Poly/ML 5.1 ... 5.5. |
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 |
2301 | 8 |
|
9 |
||
10 |
## diagnostics |
|
11 |
||
40544 | 12 |
function fail() |
13 |
{ |
|
14 |
echo "$1" >&2 |
|
15 |
exit 2 |
|
16 |
} |
|
17 |
||
2349 | 18 |
function fail_out() |
2301 | 19 |
{ |
40544 | 20 |
fail "Unable to create output heap file: \"$OUTFILE\"" |
2301 | 21 |
} |
22 |
||
10206 | 23 |
function check_file() |
5063 | 24 |
{ |
40544 | 25 |
[ ! -f "$1" ] && fail "Unable to locate \"$1\"" |
5063 | 26 |
} |
27 |
||
2301 | 28 |
|
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
29 |
## compiler executables and libraries |
16374 | 30 |
|
40544 | 31 |
[ -z "$ML_HOME" ] && fail "Missing ML installation (ML_HOME)" |
32 |
||
21356 | 33 |
POLY="$ML_HOME/poly" |
10206 | 34 |
check_file "$POLY" |
2301 | 35 |
|
52831 | 36 |
librarypath "$ML_HOME" |
10206 | 37 |
|
9765 | 38 |
|
39 |
||
2301 | 40 |
## prepare databases |
41 |
||
42 |
if [ -z "$INFILE" ]; then |
|
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
43 |
INIT="" |
48662 | 44 |
EXIT="fun exit rc : unit = Posix.Process.exit (Word8.fromInt rc);" |
10105 | 45 |
else |
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
46 |
check_file "$INFILE" |
51099
2ef891f99d2c
more thorough error handling of load/save (see also c1be3072ea8f);
wenzelm
parents:
48662
diff
changeset
|
47 |
INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ())); PolyML.SaveState.loadState \"$INFILE\" handle exn => (TextIO.output (TextIO.stdErr, General.exnMessage exn ^ \": $INFILE\\n\"); Posix.Process.exit 0w1));" |
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
48 |
EXIT="" |
2301 | 49 |
fi |
50 |
||
51 |
if [ -z "$OUTFILE" ]; then |
|
39619 | 52 |
COMMIT='fun commit () = false;' |
53 |
MLEXIT="" |
|
2301 | 54 |
else |
51099
2ef891f99d2c
more thorough error handling of load/save (see also c1be3072ea8f);
wenzelm
parents:
48662
diff
changeset
|
55 |
COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true) handle exn => (TextIO.output (TextIO.stdErr, General.exnMessage exn ^ \": $OUTFILE\\n\"); Posix.Process.exit 0w1);" |
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
56 |
[ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
39619 | 57 |
MLEXIT="commit();" |
2301 | 58 |
fi |
59 |
||
60 |
||
61 |
## run it! |
|
62 |
||
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
63 |
MLTEXT="$INIT $EXIT $COMMIT $MLTEXT" |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
64 |
|
16254
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
65 |
if [ -z "$TERMINATE" ]; then |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
66 |
FEEDER_OPTS="" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
67 |
else |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
68 |
FEEDER_OPTS="-q" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
69 |
fi |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
70 |
|
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
71 |
"$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:
41614
diff
changeset
|
72 |
{ read FPID; "$POLY" -q $ML_OPTIONS; RC="$?"; kill -TERM "$FPID"; exit "$RC"; } |
9789 | 73 |
RC="$?" |
2301 | 74 |
|
4505 | 75 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 76 |
|
9789 | 77 |
exit "$RC" |
40480 | 78 |
|
79 |
#:wrap=soft:maxLineLen=100: |