lib/Tools/build
author wenzelm
Wed Aug 08 15:58:40 2012 +0200 (2012-08-08)
changeset 48737 f3bbb9ca57d6
parent 48601 655b08c2cd89
child 48780 49a965020394
permissions -rwxr-xr-x
added build option -D: include session directory and select its sessions;
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@48737
    29
  echo "    -D DIR       include session directory and select its sessions"
wenzelm@48570
    30
  echo "    -a           select all sessions"
wenzelm@48511
    31
  echo "    -b           build heap images"
wenzelm@48595
    32
  echo "    -c           clean build"
wenzelm@48737
    33
  echo "    -d DIR       include session directory"
wenzelm@48570
    34
  echo "    -g NAME      select session group NAME"
wenzelm@48578
    35
  echo "    -j INT       maximum number of parallel jobs (default 1)"
wenzelm@48469
    36
  echo "    -n           no build -- test dependencies only"
wenzelm@48276
    37
  echo "    -o OPTION    override session configuration OPTION (via NAME=VAL or NAME)"
wenzelm@48447
    38
  echo "    -s           system build mode: produce output in ISABELLE_HOME"
wenzelm@48425
    39
  echo "    -v           verbose"
wenzelm@48276
    40
  echo
wenzelm@48276
    41
  echo "  Build and manage Isabelle sessions, depending on implicit"
wenzelm@48474
    42
  show_settings "  "
wenzelm@48276
    43
  echo
wenzelm@48276
    44
  exit 1
wenzelm@48276
    45
}
wenzelm@48276
    46
wenzelm@48276
    47
function fail()
wenzelm@48276
    48
{
wenzelm@48276
    49
  echo "$1" >&2
wenzelm@48276
    50
  exit 2
wenzelm@48276
    51
}
wenzelm@48276
    52
wenzelm@48425
    53
function check_number()
wenzelm@48425
    54
{
wenzelm@48425
    55
  [ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""
wenzelm@48425
    56
}
wenzelm@48425
    57
wenzelm@48276
    58
wenzelm@48276
    59
## process command line
wenzelm@48276
    60
wenzelm@48737
    61
declare -a SELECT_DIRS=()
wenzelm@48276
    62
ALL_SESSIONS=false
wenzelm@48511
    63
BUILD_HEAP=false
wenzelm@48595
    64
CLEAN_BUILD=false
wenzelm@48737
    65
declare -a INCLUDE_DIRS=()
wenzelm@48509
    66
declare -a SESSION_GROUPS=()
wenzelm@48425
    67
MAX_JOBS=1
wenzelm@48469
    68
NO_BUILD=false
wenzelm@48509
    69
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
wenzelm@48447
    70
SYSTEM_MODE=false
wenzelm@48425
    71
VERBOSE=false
wenzelm@48276
    72
wenzelm@48737
    73
while getopts "D:abcd:g:j:no:sv" OPT
wenzelm@48276
    74
do
wenzelm@48276
    75
  case "$OPT" in
wenzelm@48737
    76
    D)
wenzelm@48737
    77
      SELECT_DIRS["${#SELECT_DIRS[@]}"]="$OPTARG"
wenzelm@48737
    78
      ;;
wenzelm@48276
    79
    a)
wenzelm@48276
    80
      ALL_SESSIONS="true"
wenzelm@48276
    81
      ;;
wenzelm@48276
    82
    b)
wenzelm@48511
    83
      BUILD_HEAP="true"
wenzelm@48276
    84
      ;;
wenzelm@48595
    85
    c)
wenzelm@48595
    86
      CLEAN_BUILD="true"
wenzelm@48595
    87
      ;;
wenzelm@48340
    88
    d)
wenzelm@48737
    89
      INCLUDE_DIRS["${#INCLUDE_DIRS[@]}"]="$OPTARG"
wenzelm@48340
    90
      ;;
wenzelm@48509
    91
    g)
wenzelm@48509
    92
      SESSION_GROUPS["${#SESSION_GROUPS[@]}"]="$OPTARG"
wenzelm@48509
    93
      ;;
wenzelm@48425
    94
    j)
wenzelm@48425
    95
      check_number "$OPTARG"
wenzelm@48425
    96
      MAX_JOBS="$OPTARG"
wenzelm@48425
    97
      ;;
wenzelm@48469
    98
    n)
wenzelm@48469
    99
      NO_BUILD="true"
wenzelm@48276
   100
      ;;
wenzelm@48276
   101
    o)
wenzelm@48276
   102
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
wenzelm@48276
   103
      ;;
wenzelm@48447
   104
    s)
wenzelm@48447
   105
      SYSTEM_MODE="true"
wenzelm@48447
   106
      ;;
wenzelm@48425
   107
    v)
wenzelm@48425
   108
      VERBOSE="true"
wenzelm@48425
   109
      ;;
wenzelm@48276
   110
    \?)
wenzelm@48276
   111
      usage
wenzelm@48276
   112
      ;;
wenzelm@48276
   113
  esac
wenzelm@48276
   114
done
wenzelm@48276
   115
wenzelm@48276
   116
shift $(($OPTIND - 1))
wenzelm@48276
   117
wenzelm@48276
   118
wenzelm@48276
   119
## main
wenzelm@48276
   120
wenzelm@48276
   121
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
wenzelm@48276
   122
wenzelm@48601
   123
if [ "$NO_BUILD" = false -a "$VERBOSE" = true ]; then
wenzelm@48474
   124
  echo "Started at $(date) ($ML_IDENTIFIER on $(hostname))"
wenzelm@48474
   125
wenzelm@48601
   126
  show_settings ""
wenzelm@48601
   127
  echo
wenzelm@48474
   128
  . "$ISABELLE_HOME/lib/scripts/timestart.bash"
wenzelm@48474
   129
fi
wenzelm@48474
   130
wenzelm@48474
   131
"$ISABELLE_TOOL" java isabelle.Build \
wenzelm@48595
   132
  "$ALL_SESSIONS" "$BUILD_HEAP" "$CLEAN_BUILD" "$MAX_JOBS" \
wenzelm@48595
   133
  "$NO_BUILD" "$SYSTEM_MODE" "$VERBOSE" \
wenzelm@48737
   134
  "${SELECT_DIRS[@]}" $'\n' "${INCLUDE_DIRS[@]}" $'\n' \
wenzelm@48737
   135
  "${SESSION_GROUPS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@"
wenzelm@48474
   136
RC="$?"
wenzelm@48474
   137
wenzelm@48601
   138
if [ "$NO_BUILD" = false -a "$VERBOSE" = true ]; then
wenzelm@48474
   139
  echo -n "Finished at "; date
wenzelm@48474
   140
wenzelm@48474
   141
  . "$ISABELLE_HOME/lib/scripts/timestop.bash"
wenzelm@48474
   142
  echo "$TIMES_REPORT"
wenzelm@48474
   143
fi
wenzelm@48474
   144
wenzelm@48474
   145
exit "$RC"