lib/Tools/options
author wenzelm
Fri Jan 01 16:40:47 2016 +0100 (2016-01-01)
changeset 62028 2ecee4679f99
parent 52735 842b5e7dcac8
child 62437 bccad0374407
permissions -rwxr-xr-x
updated for release;
wenzelm@48693
     1
#!/usr/bin/env bash
wenzelm@48693
     2
#
wenzelm@48693
     3
# Author: Makarius
wenzelm@48693
     4
#
wenzelm@48693
     5
# DESCRIPTION: print Isabelle system options
wenzelm@48693
     6
wenzelm@48693
     7
wenzelm@48693
     8
## diagnostics
wenzelm@48693
     9
wenzelm@48693
    10
PRG="$(basename "$0")"
wenzelm@48693
    11
wenzelm@48693
    12
function usage()
wenzelm@48693
    13
{
wenzelm@48693
    14
  echo
wenzelm@48693
    15
  echo "Usage: isabelle $PRG [OPTIONS] [MORE_OPTIONS ...]"
wenzelm@48693
    16
  echo
wenzelm@48693
    17
  echo "  Options are:"
wenzelm@48693
    18
  echo "    -b           include \$ISABELLE_BUILD_OPTIONS"
wenzelm@52735
    19
  echo "    -g OPTION    get value of OPTION"
wenzelm@50531
    20
  echo "    -l           list options"
wenzelm@50531
    21
  echo "    -x FILE      export options to FILE in YXML format"
wenzelm@48693
    22
  echo
wenzelm@50531
    23
  echo "  Report Isabelle system options, augmented by MORE_OPTIONS given as"
wenzelm@48693
    24
  echo "  arguments NAME=VAL or NAME."
wenzelm@48693
    25
  echo
wenzelm@48693
    26
  exit 1
wenzelm@48693
    27
}
wenzelm@48693
    28
wenzelm@48693
    29
function fail()
wenzelm@48693
    30
{
wenzelm@48693
    31
  echo "$1" >&2
wenzelm@48693
    32
  exit 2
wenzelm@48693
    33
}
wenzelm@48693
    34
wenzelm@48693
    35
wenzelm@48693
    36
## process command line
wenzelm@48693
    37
wenzelm@52055
    38
declare -a BUILD_OPTIONS=()
wenzelm@52735
    39
GET_OPTION=""
wenzelm@50531
    40
LIST_OPTIONS="false"
wenzelm@48693
    41
EXPORT_FILE=""
wenzelm@48693
    42
wenzelm@52735
    43
while getopts "bg:lx:" OPT
wenzelm@48693
    44
do
wenzelm@48693
    45
  case "$OPT" in
wenzelm@48693
    46
    b)
wenzelm@52055
    47
      eval "BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
wenzelm@48693
    48
      ;;
wenzelm@52735
    49
    g)
wenzelm@52735
    50
      GET_OPTION="$OPTARG"
wenzelm@52735
    51
      ;;
wenzelm@50531
    52
    l)
wenzelm@50531
    53
      LIST_OPTIONS="true"
wenzelm@50531
    54
      ;;
wenzelm@48693
    55
    x)
wenzelm@48693
    56
      EXPORT_FILE="$OPTARG"
wenzelm@48693
    57
      ;;
wenzelm@48693
    58
    \?)
wenzelm@48693
    59
      usage
wenzelm@48693
    60
      ;;
wenzelm@48693
    61
  esac
wenzelm@48693
    62
done
wenzelm@48693
    63
wenzelm@48693
    64
shift $(($OPTIND - 1))
wenzelm@48693
    65
wenzelm@52735
    66
[ -z "$GET_OPTION" -a "$LIST_OPTIONS" = "false" -a -z "$EXPORT_FILE" ] && usage
wenzelm@50531
    67
wenzelm@48693
    68
wenzelm@48693
    69
## main
wenzelm@48693
    70
wenzelm@52443
    71
isabelle_admin_build jars || exit $?
wenzelm@48693
    72
wenzelm@52735
    73
exec "$ISABELLE_TOOL" java isabelle.Options \
wenzelm@52735
    74
  "$GET_OPTION" "$EXPORT_FILE" "${BUILD_OPTIONS[@]}" "$@"
wenzelm@48693
    75