lib/Tools/build
author wenzelm
Tue, 17 Jul 2012 15:56:19 +0200
changeset 48276 4bd480886813
child 48340 6f4fc030882a
permissions -rwxr-xr-x
basic setup for Isabelle build tool;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     2
#
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     3
# Author: Makarius
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     4
#
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     5
# DESCRIPTION: build and manage Isabelle sessions
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     6
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     7
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     8
## diagnostics
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     9
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    10
PRG="$(basename "$0")"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    11
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    12
function usage()
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    13
{
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    14
  echo
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    15
  echo "Usage: isabelle $PRG [OPTIONS] [SESSIONS ...]"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    16
  echo
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    17
  echo "  Options are:"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    18
  echo "    -a           all sessions"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    19
  echo "    -b           build target images"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    20
  echo "    -l           list sessions only"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    21
  echo "    -o OPTION    override session configuration OPTION (via NAME=VAL or NAME)"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    22
  echo
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    23
  echo "  Build and manage Isabelle sessions, depending on implicit"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    24
  echo "  ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\""
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    25
  echo
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    26
  echo "  ML_PLATFORM=\"$ML_PLATFORM\""
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    27
  echo "  ML_HOME=\"$ML_HOME\""
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    28
  echo "  ML_SYSTEM=\"$ML_SYSTEM\""
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    29
  echo "  ML_OPTIONS=\"$ML_OPTIONS\""
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    30
  echo
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    31
  exit 1
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    32
}
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    33
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    34
function fail()
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    35
{
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    36
  echo "$1" >&2
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    37
  exit 2
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    38
}
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    39
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    40
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    41
## process command line
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    42
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    43
ALL_SESSIONS=false
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    44
BUILD_IMAGES=false
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    45
LIST_ONLY=false
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    46
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    47
eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    48
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    49
while getopts "ablo:" OPT
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    50
do
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    51
  case "$OPT" in
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    52
    a)
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    53
      ALL_SESSIONS="true"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    54
      ;;
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    55
    b)
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    56
      BUILD_IMAGES="true"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    57
      ;;
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    58
    l)
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    59
      LIST_ONLY="true"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    60
      ;;
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    61
    o)
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    62
      BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    63
      ;;
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    64
    \?)
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    65
      usage
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    66
      ;;
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    67
  esac
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    68
done
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    69
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    70
shift $(($OPTIND - 1))
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    71
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    72
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    73
## main
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    74
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    75
[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    76
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    77
exec "$ISABELLE_TOOL" java isabelle.Build \
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    78
  "$ALL_SESSIONS" "$BUILD_IMAGES" "$LIST_ONLY" "${BUILD_OPTIONS[@]}" $'\n' "$@"