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