lib/scripts/run-polyml
author wenzelm
Mon, 29 Feb 2016 20:35:06 +0100
changeset 62475 43e64c770f28
parent 62461 075ef5ec115c
child 62485 a04e26352106
permissions -rwxr-xr-x
isabelle_process executable no longer supports writable heap images;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
     2
# :mode=shellscript:
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
     3
#
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
     4
# Author: Makarius
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
     5
#
61715
5dc95d957569 speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents: 61294
diff changeset
     6
# Startup script for Poly/ML 5.6.
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
     7
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
     8
export -n HEAP_FILE ML_TEXT TERMINATE
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
     9
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    10
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    11
## diagnostics
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    12
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    13
function fail()
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    14
{
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    15
  echo "$1" >&2
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    16
  exit 2
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    17
}
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    18
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    19
function check_file()
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    20
{
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    21
  [ ! -f "$1" ] && fail "Unable to locate \"$1\""
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    22
}
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    23
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    24
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    25
## heap file
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    26
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    27
if [ -z "$HEAP_FILE" ]; then
60962
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    28
  case "$ML_PLATFORM" in
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    29
    *-windows)
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    30
      INIT="fun exit 0 = OS.Process.exit OS.Process.success | exit 1 = OS.Process.exit OS.Process.failure | exit rc = OS.Process.exit (RunCall.unsafeCast (Word8.fromInt rc));"
60962
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    31
      ;;
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    32
    *)
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    33
      INIT="fun exit rc = Posix.Process.exit (Word8.fromInt rc);"
60962
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    34
      ;;
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    35
  esac
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    36
else
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    37
  check_file "$HEAP_FILE"
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    38
  case "$ML_PLATFORM" in
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    39
    *-windows)
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    40
      PLATFORM_HEAP_FILE="$(platform_path -m "$HEAP_FILE")"
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    41
      ;;
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    42
    *)
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    43
      PLATFORM_HEAP_FILE="$HEAP_FILE"
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    44
      ;;
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    45
  esac
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    46
  INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Thread.Thread.broadcastInterrupt ())); PolyML.SaveState.loadState \"$PLATFORM_HEAP_FILE\" handle exn => (TextIO.output (TextIO.stdErr, General.exnMessage exn ^ \": $HEAP_FILE\\n\"); OS.Process.exit OS.Process.success));"
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    47
fi
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    48
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    49
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    50
## poly process
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    51
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    52
ML_TEXT="$INIT $ML_TEXT"
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    53
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    54
check_file "$ML_HOME/poly"
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    55
librarypath "$ML_HOME"
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    56
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    57
if [ -n "$TERMINATE" ]; then
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    58
  "$ML_HOME/poly" -q -i $ML_OPTIONS \
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    59
    --eval "$(perl "$ISABELLE_HOME/lib/scripts/recode.pl" "$ML_TEXT")" \
52835
0906c00bb21d recode utf8 for ML, as done in feeder.pl;
wenzelm
parents: 52833
diff changeset
    60
    --error-exit </dev/null
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    61
  RC="$?"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    62
else
62475
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    63
  "$ISABELLE_HOME/lib/scripts/feeder" -p -h "$ML_TEXT" | \
43e64c770f28 isabelle_process executable no longer supports writable heap images;
wenzelm
parents: 62461
diff changeset
    64
    { read FPID; "$ML_HOME/poly" -q -i $ML_OPTIONS; RC="$?"; kill -TERM "$FPID"; exit "$RC"; }
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    65
  RC="$?"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    66
fi
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    67
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    68
exit "$RC"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    69
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    70
#:wrap=soft:maxLineLen=100: