lib/Tools/build
author wenzelm
Wed Jul 18 19:47:10 2012 +0200 (2012-07-18)
changeset 48340 6f4fc030882a
parent 48276 4bd480886813
child 48425 0d95980e9aae
permissions -rwxr-xr-x
allow explicit specification of additional session directories;
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@48340
    20
  echo "    -d DIR       additional session directory with ROOT file"
wenzelm@48276
    21
  echo "    -l           list sessions only"
wenzelm@48276
    22
  echo "    -o OPTION    override session configuration OPTION (via NAME=VAL or NAME)"
wenzelm@48276
    23
  echo
wenzelm@48276
    24
  echo "  Build and manage Isabelle sessions, depending on implicit"
wenzelm@48276
    25
  echo "  ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\""
wenzelm@48276
    26
  echo
wenzelm@48276
    27
  echo "  ML_PLATFORM=\"$ML_PLATFORM\""
wenzelm@48276
    28
  echo "  ML_HOME=\"$ML_HOME\""
wenzelm@48276
    29
  echo "  ML_SYSTEM=\"$ML_SYSTEM\""
wenzelm@48276
    30
  echo "  ML_OPTIONS=\"$ML_OPTIONS\""
wenzelm@48276
    31
  echo
wenzelm@48276
    32
  exit 1
wenzelm@48276
    33
}
wenzelm@48276
    34
wenzelm@48276
    35
function fail()
wenzelm@48276
    36
{
wenzelm@48276
    37
  echo "$1" >&2
wenzelm@48276
    38
  exit 2
wenzelm@48276
    39
}
wenzelm@48276
    40
wenzelm@48276
    41
wenzelm@48276
    42
## process command line
wenzelm@48276
    43
wenzelm@48276
    44
ALL_SESSIONS=false
wenzelm@48276
    45
BUILD_IMAGES=false
wenzelm@48276
    46
LIST_ONLY=false
wenzelm@48276
    47
wenzelm@48340
    48
declare -a MORE_DIRS=()
wenzelm@48276
    49
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
wenzelm@48276
    50
wenzelm@48340
    51
while getopts "abd:lo:" OPT
wenzelm@48276
    52
do
wenzelm@48276
    53
  case "$OPT" in
wenzelm@48276
    54
    a)
wenzelm@48276
    55
      ALL_SESSIONS="true"
wenzelm@48276
    56
      ;;
wenzelm@48276
    57
    b)
wenzelm@48276
    58
      BUILD_IMAGES="true"
wenzelm@48276
    59
      ;;
wenzelm@48340
    60
    d)
wenzelm@48340
    61
      MORE_DIRS["${#MORE_DIRS[@]}"]="$OPTARG"
wenzelm@48340
    62
      ;;
wenzelm@48276
    63
    l)
wenzelm@48276
    64
      LIST_ONLY="true"
wenzelm@48276
    65
      ;;
wenzelm@48276
    66
    o)
wenzelm@48276
    67
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
wenzelm@48276
    68
      ;;
wenzelm@48276
    69
    \?)
wenzelm@48276
    70
      usage
wenzelm@48276
    71
      ;;
wenzelm@48276
    72
  esac
wenzelm@48276
    73
done
wenzelm@48276
    74
wenzelm@48276
    75
shift $(($OPTIND - 1))
wenzelm@48276
    76
wenzelm@48276
    77
wenzelm@48276
    78
## main
wenzelm@48276
    79
wenzelm@48276
    80
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
wenzelm@48276
    81
wenzelm@48276
    82
exec "$ISABELLE_TOOL" java isabelle.Build \
wenzelm@48340
    83
  "$ALL_SESSIONS" "$BUILD_IMAGES" "$LIST_ONLY" \
wenzelm@48340
    84
  "${MORE_DIRS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@"