lib/Tools/build
author wenzelm
Tue Jul 24 13:22:06 2012 +0200 (2012-07-24)
changeset 48474 5b9d79c6323b
parent 48469 826a771cff33
child 48509 4854ced3e9d7
permissions -rwxr-xr-x
tuned messages (cf. isabelle makeall);
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@48474
    12
function show_settings()
wenzelm@48474
    13
{
wenzelm@48474
    14
  local PREFIX="$1"
wenzelm@48474
    15
  echo "${PREFIX}ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\""
wenzelm@48474
    16
  echo
wenzelm@48474
    17
  echo "${PREFIX}ML_PLATFORM=\"$ML_PLATFORM\""
wenzelm@48474
    18
  echo "${PREFIX}ML_HOME=\"$ML_HOME\""
wenzelm@48474
    19
  echo "${PREFIX}ML_SYSTEM=\"$ML_SYSTEM\""
wenzelm@48474
    20
  echo "${PREFIX}ML_OPTIONS=\"$ML_OPTIONS\""
wenzelm@48474
    21
}
wenzelm@48474
    22
wenzelm@48276
    23
function usage()
wenzelm@48276
    24
{
wenzelm@48276
    25
  echo
wenzelm@48276
    26
  echo "Usage: isabelle $PRG [OPTIONS] [SESSIONS ...]"
wenzelm@48276
    27
  echo
wenzelm@48276
    28
  echo "  Options are:"
wenzelm@48276
    29
  echo "    -a           all sessions"
wenzelm@48276
    30
  echo "    -b           build target images"
wenzelm@48340
    31
  echo "    -d DIR       additional session directory with ROOT file"
wenzelm@48425
    32
  echo "    -j INT       maximum number of jobs (default 1)"
wenzelm@48469
    33
  echo "    -n           no build -- test dependencies only"
wenzelm@48276
    34
  echo "    -o OPTION    override session configuration OPTION (via NAME=VAL or NAME)"
wenzelm@48447
    35
  echo "    -s           system build mode: produce output in ISABELLE_HOME"
wenzelm@48459
    36
  echo "    -t           inner session timing"
wenzelm@48425
    37
  echo "    -v           verbose"
wenzelm@48276
    38
  echo
wenzelm@48276
    39
  echo "  Build and manage Isabelle sessions, depending on implicit"
wenzelm@48474
    40
  show_settings "  "
wenzelm@48276
    41
  echo
wenzelm@48276
    42
  exit 1
wenzelm@48276
    43
}
wenzelm@48276
    44
wenzelm@48276
    45
function fail()
wenzelm@48276
    46
{
wenzelm@48276
    47
  echo "$1" >&2
wenzelm@48276
    48
  exit 2
wenzelm@48276
    49
}
wenzelm@48276
    50
wenzelm@48425
    51
function check_number()
wenzelm@48425
    52
{
wenzelm@48425
    53
  [ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""
wenzelm@48425
    54
}
wenzelm@48425
    55
wenzelm@48276
    56
wenzelm@48276
    57
## process command line
wenzelm@48276
    58
wenzelm@48276
    59
ALL_SESSIONS=false
wenzelm@48276
    60
BUILD_IMAGES=false
wenzelm@48425
    61
MAX_JOBS=1
wenzelm@48469
    62
NO_BUILD=false
wenzelm@48447
    63
SYSTEM_MODE=false
wenzelm@48459
    64
TIMING=false
wenzelm@48425
    65
VERBOSE=false
wenzelm@48276
    66
wenzelm@48340
    67
declare -a MORE_DIRS=()
wenzelm@48276
    68
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
wenzelm@48276
    69
wenzelm@48469
    70
while getopts "abd:j:no:stv" OPT
wenzelm@48276
    71
do
wenzelm@48276
    72
  case "$OPT" in
wenzelm@48276
    73
    a)
wenzelm@48276
    74
      ALL_SESSIONS="true"
wenzelm@48276
    75
      ;;
wenzelm@48276
    76
    b)
wenzelm@48276
    77
      BUILD_IMAGES="true"
wenzelm@48276
    78
      ;;
wenzelm@48340
    79
    d)
wenzelm@48340
    80
      MORE_DIRS["${#MORE_DIRS[@]}"]="$OPTARG"
wenzelm@48340
    81
      ;;
wenzelm@48425
    82
    j)
wenzelm@48425
    83
      check_number "$OPTARG"
wenzelm@48425
    84
      MAX_JOBS="$OPTARG"
wenzelm@48425
    85
      ;;
wenzelm@48469
    86
    n)
wenzelm@48469
    87
      NO_BUILD="true"
wenzelm@48276
    88
      ;;
wenzelm@48276
    89
    o)
wenzelm@48276
    90
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
wenzelm@48276
    91
      ;;
wenzelm@48447
    92
    s)
wenzelm@48447
    93
      SYSTEM_MODE="true"
wenzelm@48447
    94
      ;;
wenzelm@48459
    95
    t)
wenzelm@48459
    96
      TIMING="true"
wenzelm@48459
    97
      ;;
wenzelm@48425
    98
    v)
wenzelm@48425
    99
      VERBOSE="true"
wenzelm@48425
   100
      ;;
wenzelm@48276
   101
    \?)
wenzelm@48276
   102
      usage
wenzelm@48276
   103
      ;;
wenzelm@48276
   104
  esac
wenzelm@48276
   105
done
wenzelm@48276
   106
wenzelm@48276
   107
shift $(($OPTIND - 1))
wenzelm@48276
   108
wenzelm@48276
   109
wenzelm@48276
   110
## main
wenzelm@48276
   111
wenzelm@48276
   112
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
wenzelm@48276
   113
wenzelm@48474
   114
if [ "$NO_BUILD" = false ]; then
wenzelm@48474
   115
  echo "Started at $(date) ($ML_IDENTIFIER on $(hostname))"
wenzelm@48474
   116
wenzelm@48474
   117
  if [ "$VERBOSE" = true ]; then
wenzelm@48474
   118
    show_settings ""
wenzelm@48474
   119
    echo
wenzelm@48474
   120
  fi
wenzelm@48474
   121
  . "$ISABELLE_HOME/lib/scripts/timestart.bash"
wenzelm@48474
   122
fi
wenzelm@48474
   123
wenzelm@48474
   124
"$ISABELLE_TOOL" java isabelle.Build \
wenzelm@48469
   125
  "$ALL_SESSIONS" "$BUILD_IMAGES" "$MAX_JOBS" "$NO_BUILD" "$SYSTEM_MODE" "$TIMING" \
wenzelm@48459
   126
  "$VERBOSE" "${MORE_DIRS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@"
wenzelm@48474
   127
RC="$?"
wenzelm@48474
   128
wenzelm@48474
   129
if [ "$NO_BUILD" = false ]; then
wenzelm@48474
   130
  echo -n "Finished at "; date
wenzelm@48474
   131
wenzelm@48474
   132
  . "$ISABELLE_HOME/lib/scripts/timestop.bash"
wenzelm@48474
   133
  echo "$TIMES_REPORT"
wenzelm@48474
   134
fi
wenzelm@48474
   135
wenzelm@48474
   136
exit "$RC"