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