lib/Tools/build
author wenzelm
Tue Jul 17 15:56:19 2012 +0200 (2012-07-17)
changeset 48276 4bd480886813
child 48340 6f4fc030882a
permissions -rwxr-xr-x
basic setup for Isabelle build tool;
wenzelm@48276
     1
#!/usr/bin/env bash
wenzelm@48276
     2
#
wenzelm@48276
     3
# Author: Makarius
wenzelm@48276
     4
#
wenzelm@48276
     5
# DESCRIPTION: build and manage Isabelle sessions
wenzelm@48276
     6
wenzelm@48276
     7
wenzelm@48276
     8
## diagnostics
wenzelm@48276
     9
wenzelm@48276
    10
PRG="$(basename "$0")"
wenzelm@48276
    11
wenzelm@48276
    12
function usage()
wenzelm@48276
    13
{
wenzelm@48276
    14
  echo
wenzelm@48276
    15
  echo "Usage: isabelle $PRG [OPTIONS] [SESSIONS ...]"
wenzelm@48276
    16
  echo
wenzelm@48276
    17
  echo "  Options are:"
wenzelm@48276
    18
  echo "    -a           all sessions"
wenzelm@48276
    19
  echo "    -b           build target images"
wenzelm@48276
    20
  echo "    -l           list sessions only"
wenzelm@48276
    21
  echo "    -o OPTION    override session configuration OPTION (via NAME=VAL or NAME)"
wenzelm@48276
    22
  echo
wenzelm@48276
    23
  echo "  Build and manage Isabelle sessions, depending on implicit"
wenzelm@48276
    24
  echo "  ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\""
wenzelm@48276
    25
  echo
wenzelm@48276
    26
  echo "  ML_PLATFORM=\"$ML_PLATFORM\""
wenzelm@48276
    27
  echo "  ML_HOME=\"$ML_HOME\""
wenzelm@48276
    28
  echo "  ML_SYSTEM=\"$ML_SYSTEM\""
wenzelm@48276
    29
  echo "  ML_OPTIONS=\"$ML_OPTIONS\""
wenzelm@48276
    30
  echo
wenzelm@48276
    31
  exit 1
wenzelm@48276
    32
}
wenzelm@48276
    33
wenzelm@48276
    34
function fail()
wenzelm@48276
    35
{
wenzelm@48276
    36
  echo "$1" >&2
wenzelm@48276
    37
  exit 2
wenzelm@48276
    38
}
wenzelm@48276
    39
wenzelm@48276
    40
wenzelm@48276
    41
## process command line
wenzelm@48276
    42
wenzelm@48276
    43
ALL_SESSIONS=false
wenzelm@48276
    44
BUILD_IMAGES=false
wenzelm@48276
    45
LIST_ONLY=false
wenzelm@48276
    46
wenzelm@48276
    47
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
wenzelm@48276
    48
wenzelm@48276
    49
while getopts "ablo:" OPT
wenzelm@48276
    50
do
wenzelm@48276
    51
  case "$OPT" in
wenzelm@48276
    52
    a)
wenzelm@48276
    53
      ALL_SESSIONS="true"
wenzelm@48276
    54
      ;;
wenzelm@48276
    55
    b)
wenzelm@48276
    56
      BUILD_IMAGES="true"
wenzelm@48276
    57
      ;;
wenzelm@48276
    58
    l)
wenzelm@48276
    59
      LIST_ONLY="true"
wenzelm@48276
    60
      ;;
wenzelm@48276
    61
    o)
wenzelm@48276
    62
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
wenzelm@48276
    63
      ;;
wenzelm@48276
    64
    \?)
wenzelm@48276
    65
      usage
wenzelm@48276
    66
      ;;
wenzelm@48276
    67
  esac
wenzelm@48276
    68
done
wenzelm@48276
    69
wenzelm@48276
    70
shift $(($OPTIND - 1))
wenzelm@48276
    71
wenzelm@48276
    72
wenzelm@48276
    73
## main
wenzelm@48276
    74
wenzelm@48276
    75
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
wenzelm@48276
    76
wenzelm@48276
    77
exec "$ISABELLE_TOOL" java isabelle.Build \
wenzelm@48276
    78
  "$ALL_SESSIONS" "$BUILD_IMAGES" "$LIST_ONLY" "${BUILD_OPTIONS[@]}" $'\n' "$@"