lib/scripts/run-polyml-5.6
author wenzelm
Fri, 01 Jan 2016 16:51:04 +0100
changeset 62030 2b46a93e829c
parent 61715 5dc95d957569
child 62386 10e55e168672
permissions -rwxr-xr-x
Added tag Isabelle2016-RC0 for changeset e18444532fce
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
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
     8
export -n INFILE OUTFILE MLTEXT TERMINATE NOWRITE
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 fail_out()
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
  fail "Unable to create output heap file: \"$OUTFILE\""
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
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
    25
{
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    26
  [ ! -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
    27
}
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    28
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    29
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    30
## compiler executables and libraries
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    31
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    32
[ -z "$ML_HOME" ] && fail "Missing ML installation (ML_HOME)"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    33
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    34
POLY="$ML_HOME/poly"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    35
check_file "$POLY"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    36
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    37
librarypath "$ML_HOME"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    38
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    39
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    40
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    41
## prepare databases
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    42
60967
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    43
case "$ML_PLATFORM" in
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    44
  *-windows)
61294
2d3d26e9b191 renamed jvmpath to platform_path;
wenzelm
parents: 60967
diff changeset
    45
    PLATFORM_INFILE="$(platform_path -m "$INFILE")"
2d3d26e9b191 renamed jvmpath to platform_path;
wenzelm
parents: 60967
diff changeset
    46
    PLATFORM_OUTFILE="$(platform_path -m "$OUTFILE")"
60967
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    47
    ;;
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    48
  *)
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    49
    PLATFORM_INFILE="$INFILE"
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    50
    PLATFORM_OUTFILE="$OUTFILE"
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    51
    ;;
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    52
esac
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    53
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    54
if [ -z "$INFILE" ]; then
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    55
  INIT=""
60962
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    56
  case "$ML_PLATFORM" in
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    57
    *-windows)
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    58
      EXIT="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));"
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    59
      ;;
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    60
    *)
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    61
      EXIT="fun exit rc = Posix.Process.exit (Word8.fromInt rc);"
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    62
      ;;
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 59344
diff changeset
    63
  esac
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    64
else
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    65
  check_file "$INFILE"
60966
ad3c5eb9e348 proper platform path for initial load;
wenzelm
parents: 60962
diff changeset
    66
  INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ())); PolyML.SaveState.loadState \"$PLATFORM_INFILE\" handle exn => (TextIO.output (TextIO.stdErr, General.exnMessage exn ^ \": $INFILE\\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
    67
  EXIT=""
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    68
fi
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
if [ -z "$OUTFILE" ]; then
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    71
  MLEXIT=""
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    72
else
53657
64942a1f7187 prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
wenzelm
parents: 52835
diff changeset
    73
  if [ -z "$INFILE" ]; then
60967
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60966
diff changeset
    74
    MLEXIT="(PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$PLATFORM_OUTFILE\"; true) handle exn => (TextIO.output (TextIO.stdErr, General.exnMessage exn ^ \": $OUTFILE\\n\"); OS.Process.exit OS.Process.success);"
53657
64942a1f7187 prefer high-level ML_System.share_common_data, ML_System.save_state -- except for bootstrap images (RAW, Pure);
wenzelm
parents: 52835
diff changeset
    75
  else
59344
e0ce214303c1 proper Session.save with shutdown, which is relevant to avoid persistent threads;
wenzelm
parents: 58470
diff changeset
    76
    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: 52835
diff changeset
    77
  fi
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    78
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    79
fi
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    80
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    81
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    82
## run it!
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    83
59344
e0ce214303c1 proper Session.save with shutdown, which is relevant to avoid persistent threads;
wenzelm
parents: 58470
diff changeset
    84
MLTEXT="$INIT $EXIT $MLTEXT"
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    85
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    86
if [ -n "$TERMINATE" -a -z "$MLEXIT" ]; then
52835
0906c00bb21d recode utf8 for ML, as done in feeder.pl;
wenzelm
parents: 52833
diff changeset
    87
  "$POLY" -q -i $ML_OPTIONS --eval "$(perl "$ISABELLE_HOME/lib/scripts/recode.pl" "$MLTEXT")" \
0906c00bb21d recode utf8 for ML, as done in feeder.pl;
wenzelm
parents: 52833
diff changeset
    88
    --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
    89
  RC="$?"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    90
else
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    91
  if [ -z "$TERMINATE" ]; then
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    92
    FEEDER_OPTS=""
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    93
  else
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    94
    FEEDER_OPTS="-q"
52833
21843a4c6ba9 clarified options;
wenzelm
parents: 52832
diff changeset
    95
    ML_OPTIONS="$ML_OPTIONS --error-exit"
52832
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    96
  fi
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    97
  "$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    98
    { read FPID; "$POLY" -q -i $ML_OPTIONS; RC="$?"; kill -TERM "$FPID"; exit "$RC"; }
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
    99
  RC="$?"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
   100
fi
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
   101
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
   102
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
   103
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
   104
exit "$RC"
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
   105
980ca3d6ded4 specific startup script for Poly/ML 5.5.1, taking advantage of some of its new options;
wenzelm
parents:
diff changeset
   106
#:wrap=soft:maxLineLen=100: