lib/Tools/console
author wenzelm
Sun, 20 Jul 2014 17:21:14 +0200
changeset 57580 86b413b8f779
parent 57439 0e41f26a0250
child 57581 74bbe9317aa4
permissions -rwxr-xr-x
check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
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
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     7
PRG="$(basename "$0")"
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     8
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
     9
function usage()
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    10
{
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    11
  echo
28650
a7ba12e0d3b7 tuned usage line;
wenzelm
parents: 28502
diff changeset
    12
  echo "Usage: isabelle $PRG [OPTIONS]"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    13
  echo
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    14
  echo "  Options are:"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    15
  echo "    -d DIR       include session directory"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    16
  echo "    -l NAME      logic session name (default ISABELLE_LOGIC=\"$ISABELLE_LOGIC\")"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    17
  echo "    -m MODE      add print mode for output"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    18
  echo "    -n           no build of session image on startup"
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    19
  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
    20
  echo "    -s           system build mode for session image"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    21
  echo
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    22
  echo "  Run Isabelle process with raw ML console and line editor"
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    23
  echo "  (ISABELLE_LINE_EDITOR=\"$ISABELLE_LINE_EDITOR\")."
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    24
  echo
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    25
  exit 1
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    26
}
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    27
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    28
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    29
## process command line
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    30
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    31
# options
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    32
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    33
declare -a ISABELLE_OPTIONS=()
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    34
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    35
declare -a INCLUDE_DIRS=()
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    36
LOGIC="$ISABELLE_LOGIC"
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    37
NO_BUILD="false"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    38
declare -a BUILD_OPTIONS=()
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    39
SYSTEM_MODE="false"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    40
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    41
while getopts "d:l:m:no:s" OPT
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    42
do
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    43
  case "$OPT" in
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    44
    d)
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    45
      INCLUDE_DIRS["${#INCLUDE_DIRS[@]}"]="$OPTARG"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    46
      ;;
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    47
    l)
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    48
      LOGIC="$OPTARG"
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    49
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    50
    m)
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    51
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="-m"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    52
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="$OPTARG"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    53
      ;;
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    54
    n)
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    55
      NO_BUILD="true"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    56
      ;;
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    57
    o)
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    58
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="-o"
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    59
      ISABELLE_OPTIONS["${#ISABELLE_OPTIONS[@]}"]="$OPTARG"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    60
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    61
      ;;
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    62
    s)
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    63
      SYSTEM_MODE="true"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    64
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    65
    \?)
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    66
      usage
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    67
      ;;
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    68
  esac
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    69
done
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    70
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    71
shift $(($OPTIND - 1))
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    72
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    73
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    74
# args
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    75
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    76
[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; }
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
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    79
## main
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    80
57580
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    81
isabelle_admin_build jars || exit $?
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    82
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    83
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
    84
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    85
"$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" isabelle.Build_Console \
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    86
  "$LOGIC" "$NO_BUILD" "$SYSTEM_MODE" \
86b413b8f779 check and build Isabelle session for console tool -- avoid multiple Scala/JVM invocation;
wenzelm
parents: 57439
diff changeset
    87
  "${INCLUDE_DIRS[@]}" $'\n' "${BUILD_OPTIONS[@]}" || exit "$?"
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    88
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    89
if type -p "$ISABELLE_LINE_EDITOR" > /dev/null
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    90
then
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    91
  exec "$ISABELLE_LINE_EDITOR" "$ISABELLE_PROCESS" "${ISABELLE_OPTIONS[@]}" -- "$LOGIC"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    92
else
57439
0e41f26a0250 "isabelle tty" is superseded by "isabelle console";
wenzelm
parents: 52062
diff changeset
    93
  echo "### No line editor: \"$ISABELLE_LINE_EDITOR\""
52062
4f91262e7f33 added isabelle tty option -o;
wenzelm
parents: 48572
diff changeset
    94
  exec "$ISABELLE_PROCESS" "${ISABELLE_OPTIONS[@]}" -- "$LOGIC"
25632
01a8d27a0857 run Isabelle process with plain tty interaction;
wenzelm
parents:
diff changeset
    95
fi