lib/Tools/console
author wenzelm
Wed, 10 Feb 2016 14:14:43 +0100
changeset 62278 c04e97be39d3
parent 62047 1ae53588dcbb
child 62509 13d6948e4b12
permissions -rwxr-xr-x
misc tuning and updates;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     2
#
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
     3
# Author: Makarius
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     4
#
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
     5
# DESCRIPTION: run Isabelle process with raw ML console and line editor
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     6
61135
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
     7
## settings
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
     8
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
     9
case "$ISABELLE_JAVA_PLATFORM" in
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    10
  x86-*)
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    11
    ISABELLE_BUILD_JAVA_OPTIONS="$ISABELLE_BUILD_JAVA_OPTIONS32"
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    12
    ;;
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    13
  x86_64-*)
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    14
    ISABELLE_BUILD_JAVA_OPTIONS="$ISABELLE_BUILD_JAVA_OPTIONS64"
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    15
    ;;
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    16
esac
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    17
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    18
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    19
## diagnostics
8f7d802b7a71 clarified Java runtime options (NB: ISABELLE_JAVA_PLATFORM is determined later via component);
wenzelm
parents: 57686
diff changeset
    20
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    21
PRG="$(basename "$0")"
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    22
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    23
function usage()
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    24
{
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    25
  echo
28650
a7ba12e0d3b7 tuned usage line;
wenzelm
parents: 28502
diff changeset
    26
  echo "Usage: isabelle $PRG [OPTIONS]"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    27
  echo
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    28
  echo "  Options are:"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    29
  echo "    -d DIR       include session directory"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    30
  echo "    -l NAME      logic session name (default ISABELLE_LOGIC=\"$ISABELLE_LOGIC\")"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    31
  echo "    -m MODE      add print mode for output"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    32
  echo "    -n           no build of session image on startup"
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    33
  echo "    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    34
  echo "    -s           system build mode for session image"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    35
  echo
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    36
  echo "  Run Isabelle process with raw ML console and line editor"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    37
  echo "  (ISABELLE_LINE_EDITOR=\"$ISABELLE_LINE_EDITOR\")."
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    38
  echo
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    39
  exit 1
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    40
}
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    41
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    42
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    43
## process command line
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    44
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    45
# options
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    46
62047
1ae53588dcbb proper treatment of RAW bootstrap session;
wenzelm
parents: 61958
diff changeset
    47
declare -a ISABELLE_OPTIONS=()
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    48
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    49
declare -a INCLUDE_DIRS=()
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    50
LOGIC="$ISABELLE_LOGIC"
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    51
NO_BUILD="false"
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    52
declare -a SYSTEM_OPTIONS=()
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    53
SYSTEM_MODE="false"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    54
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    55
while getopts "d:l:m:no:s" OPT
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    56
do
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    57
  case "$OPT" in
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    58
    d)
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    59
      INCLUDE_DIRS["${#INCLUDE_DIRS[@]}"]="$OPTARG"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    60
      ;;
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    61
    l)
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    62
      LOGIC="$OPTARG"
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    63
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    64
    m)
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    65
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="-m"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    66
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="$OPTARG"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    67
      ;;
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    68
    n)
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    69
      NO_BUILD="true"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    70
      ;;
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    71
    o)
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    72
      SYSTEM_OPTIONS["${#SYSTEM_OPTIONS[@]}"]="$OPTARG"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    73
      ;;
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    74
    s)
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    75
      SYSTEM_MODE="true"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    76
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    77
    \?)
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    78
      usage
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    79
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    80
  esac
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    81
done
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    82
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    83
shift $(($OPTIND - 1))
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    84
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    85
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    86
# args
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    87
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    88
[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; }
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    89
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    90
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    91
## main
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    92
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    93
isabelle_admin_build jars || exit $?
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    94
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    95
declare -a JAVA_ARGS; eval "JAVA_ARGS=($ISABELLE_BUILD_JAVA_OPTIONS)"
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    96
57686
5b16e2370ccb proper mkdir;
wenzelm
parents: 57581
diff changeset
    97
mkdir -p "$ISABELLE_TMP_PREFIX" || exit $?
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    98
OPTIONS_FILE="$ISABELLE_TMP_PREFIX/options$$"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
    99
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
   100
"$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" isabelle.Build_Console \
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
   101
  "$LOGIC" "$NO_BUILD" "$SYSTEM_MODE" "$OPTIONS_FILE" \
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
   102
  "${INCLUDE_DIRS[@]}" $'\n' "${SYSTEM_OPTIONS[@]}" || {
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
   103
  rm -f "$OPTIONS_FILE"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
   104
  exit "$?"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
   105
}
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
   106
62047
1ae53588dcbb proper treatment of RAW bootstrap session;
wenzelm
parents: 61958
diff changeset
   107
if [ "$LOGIC" != "RAW" ]; then
1ae53588dcbb proper treatment of RAW bootstrap session;
wenzelm
parents: 61958
diff changeset
   108
  ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="-m"
1ae53588dcbb proper treatment of RAW bootstrap session;
wenzelm
parents: 61958
diff changeset
   109
  ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="ASCII"
1ae53588dcbb proper treatment of RAW bootstrap session;
wenzelm
parents: 61958
diff changeset
   110
fi
1ae53588dcbb proper treatment of RAW bootstrap session;
wenzelm
parents: 61958
diff changeset
   111
57581
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
   112
ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="-O"
74bbe9317aa4 provide explicit options file -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57580
diff changeset
   113
ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="$OPTIONS_FILE"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
   114
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
   115
if type -p "$ISABELLE_LINE_EDITOR" > /dev/null
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
   116
then
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
   117
  exec "$ISABELLE_LINE_EDITOR" "$ISABELLE_PROCESS" "${ISABELLE_OPTIONS[@]}" -- "$LOGIC"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
   118
else
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
   119
  echo "### No line editor: \"$ISABELLE_LINE_EDITOR\""
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
   120
  exec "$ISABELLE_PROCESS" "${ISABELLE_OPTIONS[@]}" -- "$LOGIC"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
   121
fi