lib/Tools/build
author wenzelm
Sun Jul 22 23:31:57 2012 +0200 (2012-07-22)
changeset 48425 0d95980e9aae
parent 48340 6f4fc030882a
child 48447 ef600ce4559c
permissions -rwxr-xr-x
parallel scheduling of jobs;
misc tuning;
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@48425
    21
  echo "    -j INT       maximum number of jobs (default 1)"
wenzelm@48276
    22
  echo "    -l           list sessions only"
wenzelm@48276
    23
  echo "    -o OPTION    override session configuration OPTION (via NAME=VAL or NAME)"
wenzelm@48425
    24
  echo "    -v           verbose"
wenzelm@48276
    25
  echo
wenzelm@48276
    26
  echo "  Build and manage Isabelle sessions, depending on implicit"
wenzelm@48276
    27
  echo "  ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\""
wenzelm@48276
    28
  echo
wenzelm@48276
    29
  echo "  ML_PLATFORM=\"$ML_PLATFORM\""
wenzelm@48276
    30
  echo "  ML_HOME=\"$ML_HOME\""
wenzelm@48276
    31
  echo "  ML_SYSTEM=\"$ML_SYSTEM\""
wenzelm@48276
    32
  echo "  ML_OPTIONS=\"$ML_OPTIONS\""
wenzelm@48276
    33
  echo
wenzelm@48276
    34
  exit 1
wenzelm@48276
    35
}
wenzelm@48276
    36
wenzelm@48276
    37
function fail()
wenzelm@48276
    38
{
wenzelm@48276
    39
  echo "$1" >&2
wenzelm@48276
    40
  exit 2
wenzelm@48276
    41
}
wenzelm@48276
    42
wenzelm@48425
    43
function check_number()
wenzelm@48425
    44
{
wenzelm@48425
    45
  [ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""
wenzelm@48425
    46
}
wenzelm@48425
    47
wenzelm@48276
    48
wenzelm@48276
    49
## process command line
wenzelm@48276
    50
wenzelm@48276
    51
ALL_SESSIONS=false
wenzelm@48276
    52
BUILD_IMAGES=false
wenzelm@48425
    53
MAX_JOBS=1
wenzelm@48276
    54
LIST_ONLY=false
wenzelm@48425
    55
VERBOSE=false
wenzelm@48276
    56
wenzelm@48340
    57
declare -a MORE_DIRS=()
wenzelm@48276
    58
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
wenzelm@48276
    59
wenzelm@48425
    60
while getopts "abd:j:lo:v" OPT
wenzelm@48276
    61
do
wenzelm@48276
    62
  case "$OPT" in
wenzelm@48276
    63
    a)
wenzelm@48276
    64
      ALL_SESSIONS="true"
wenzelm@48276
    65
      ;;
wenzelm@48276
    66
    b)
wenzelm@48276
    67
      BUILD_IMAGES="true"
wenzelm@48276
    68
      ;;
wenzelm@48340
    69
    d)
wenzelm@48340
    70
      MORE_DIRS["${#MORE_DIRS[@]}"]="$OPTARG"
wenzelm@48340
    71
      ;;
wenzelm@48425
    72
    j)
wenzelm@48425
    73
      check_number "$OPTARG"
wenzelm@48425
    74
      MAX_JOBS="$OPTARG"
wenzelm@48425
    75
      ;;
wenzelm@48276
    76
    l)
wenzelm@48276
    77
      LIST_ONLY="true"
wenzelm@48276
    78
      ;;
wenzelm@48276
    79
    o)
wenzelm@48276
    80
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
wenzelm@48276
    81
      ;;
wenzelm@48425
    82
    v)
wenzelm@48425
    83
      VERBOSE="true"
wenzelm@48425
    84
      ;;
wenzelm@48276
    85
    \?)
wenzelm@48276
    86
      usage
wenzelm@48276
    87
      ;;
wenzelm@48276
    88
  esac
wenzelm@48276
    89
done
wenzelm@48276
    90
wenzelm@48276
    91
shift $(($OPTIND - 1))
wenzelm@48276
    92
wenzelm@48276
    93
wenzelm@48276
    94
## main
wenzelm@48276
    95
wenzelm@48276
    96
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
wenzelm@48276
    97
wenzelm@48276
    98
exec "$ISABELLE_TOOL" java isabelle.Build \
wenzelm@48425
    99
  "$ALL_SESSIONS" "$BUILD_IMAGES" "$MAX_JOBS" "$LIST_ONLY" "$VERBOSE" \
wenzelm@48340
   100
  "${MORE_DIRS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@"