lib/scripts/run-polyml
author wenzelm
Sat, 10 Jan 2009 21:32:30 +0100
changeset 29435 a5f84ac14609
parent 29145 b1c6f4563df7
child 31315 3c7b40548a84
permissions -rwxr-xr-x
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10555
2323ec838401 /usr/bin/env bash;
wenzelm
parents: 10206
diff changeset
     1
#!/usr/bin/env bash
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     2
#
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
     3
# Author: Makarius
2314
67bf78c7c725 replaced cat by ucat;
wenzelm
parents: 2301
diff changeset
     4
#
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
     5
# Poly/ML 5.1/5.2 startup script.
9977
32955afeb835 unexport exports;
wenzelm
parents: 9789
diff changeset
     6
10105
f9be78009930 added COPYDB argument;
wenzelm
parents: 9997
diff changeset
     7
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     8
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     9
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    10
## diagnostics
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    11
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    12
function fail_out()
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    13
{
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    14
  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    15
  exit 2
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    16
}
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    17
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    18
function check_file()
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    19
{
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    20
  if [ ! -f "$1" ]; then
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    21
    echo "Unable to locate $1" >&2
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    22
    echo "Please check your ML system settings!" >&2
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    23
    exit 2
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    24
  fi
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    25
}
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    26
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    27
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    28
## compiler executables and libraries
16374
f4b7cf8975af some cygwin support;
wenzelm
parents: 16285
diff changeset
    29
21356
556addc67737 removed old cygwin wrappers;
wenzelm
parents: 18166
diff changeset
    30
POLY="$ML_HOME/poly"
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    31
check_file "$POLY"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    32
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    33
if [ "$(basename "$ML_HOME")" = bin ]; then
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    34
  POLYLIB="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib; pwd)"
16392
7212040b71f2 discontinued polyml-3.x;
wenzelm
parents: 16374
diff changeset
    35
else
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    36
  POLYLIB="$ML_HOME"
16392
7212040b71f2 discontinued polyml-3.x;
wenzelm
parents: 16374
diff changeset
    37
fi
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    38
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    39
export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH"
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    40
export DYLD_LIBRARY_PATH="$POLYLIB:$DYLD_LIBRARY_PATH"
9765
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    41
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    42
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    43
## prepare databases
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    44
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    45
if [ -z "$INFILE" ]; then
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    46
  INIT=""
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    47
  EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
10105
f9be78009930 added COPYDB argument;
wenzelm
parents: 9997
diff changeset
    48
else
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    49
  check_file "$INFILE"
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    50
  INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ())); PolyML.SaveState.loadState \"$INFILE\" handle Fail msg => (TextIO.output (TextIO.stdErr, msg ^ \"\\n\"); OS.Process.exit OS.Process.failure));"
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    51
  EXIT=""
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    52
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    53
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    54
if [ -z "$OUTFILE" ]; then
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    55
  COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);'
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    56
else
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    57
  if [ -z "$COMPRESS" ]; then
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    58
    COMMIT="fun commit () = (TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);"
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    59
  else
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    60
    COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);"
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    61
  fi
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    62
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    63
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    64
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    65
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    66
## run it!
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    67
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    68
MLTEXT="$INIT $EXIT $COMMIT $MLTEXT"
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    69
MLEXIT="commit();"
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    70
16254
1b2683e18fd2 DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents: 15850
diff changeset
    71
if [ -z "$TERMINATE" ]; then
1b2683e18fd2 DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents: 15850
diff changeset
    72
  FEEDER_OPTS=""
1b2683e18fd2 DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents: 15850
diff changeset
    73
else
1b2683e18fd2 DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents: 15850
diff changeset
    74
  FEEDER_OPTS="-q"
1b2683e18fd2 DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents: 15850
diff changeset
    75
fi
1b2683e18fd2 DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents: 15850
diff changeset
    76
26215
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    77
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
94d32a7cd0fb rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents: 25123
diff changeset
    78
  { read FPID; "$POLY" -q $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
9789
wenzelm
parents: 9765
diff changeset
    79
RC="$?"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    80
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
    81
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    82
9789
wenzelm
parents: 9765
diff changeset
    83
exit "$RC"