| author | blanchet | 
| Tue, 09 Sep 2014 22:33:43 +0200 | |
| changeset 58289 | eb93bc67d361 | 
| parent 56627 | cb912b7de3cf | 
| child 59344 | e0ce214303c1 | 
| 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: 
25123diff
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: 
31315diff
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: 
25123diff
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: 
25123diff
changeset | 43 | INIT="" | 
| 56627 | 44 | EXIT="fun exit rc = 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: 
25123diff
changeset | 46 | check_file "$INFILE" | 
| 51099 
2ef891f99d2c
more thorough error handling of load/save (see also c1be3072ea8f);
 wenzelm parents: 
48662diff
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: 
25123diff
changeset | 48 | EXIT="" | 
| 2301 | 49 | fi | 
| 50 | ||
| 51 | if [ -z "$OUTFILE" ]; then | |
| 39619 | 52 | COMMIT='fun commit () = false;' | 
| 53 | MLEXIT="" | |
| 2301 | 54 | else | 
| 53657 
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
 wenzelm parents: 
52831diff
changeset | 55 | if [ -z "$INFILE" ]; then | 
| 
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
 wenzelm parents: 
52831diff
changeset | 56 | 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);" | 
| 
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
 wenzelm parents: 
52831diff
changeset | 57 | else | 
| 
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
 wenzelm parents: 
52831diff
changeset | 58 | COMMIT="fun commit () = (ML_System.share_common_data (); ML_System.save_state \"$OUTFILE\");" | 
| 
64942a1f7187
prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
 wenzelm parents: 
52831diff
changeset | 59 | fi | 
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 60 |   [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
 | 
| 39619 | 61 | MLEXIT="commit();" | 
| 2301 | 62 | fi | 
| 63 | ||
| 64 | ||
| 65 | ## run it! | |
| 66 | ||
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 67 | MLTEXT="$INIT $EXIT $COMMIT $MLTEXT" | 
| 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 68 | |
| 16254 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 69 | if [ -z "$TERMINATE" ]; then | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 70 | FEEDER_OPTS="" | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 71 | else | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 72 | FEEDER_OPTS="-q" | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 73 | fi | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 74 | |
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 75 | "$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: 
41614diff
changeset | 76 |   { read FPID; "$POLY" -q $ML_OPTIONS; RC="$?"; kill -TERM "$FPID"; exit "$RC"; }
 | 
| 9789 | 77 | RC="$?" | 
| 2301 | 78 | |
| 4505 | 79 | [ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" | 
| 2301 | 80 | |
| 9789 | 81 | exit "$RC" | 
| 40480 | 82 | |
| 83 | #:wrap=soft:maxLineLen=100: |