lib/Tools/build
author wenzelm
Sun Jul 22 23:31:57 2012 +0200 (2012-07-22)
changeset 48425 0d95980e9aae
parent 48340 6f4fc030882a
child 48447 ef600ce4559c
permissions -rwxr-xr-x
parallel scheduling of jobs;
misc tuning;
     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 "    -j INT       maximum number of jobs (default 1)"
    22   echo "    -l           list sessions only"
    23   echo "    -o OPTION    override session configuration OPTION (via NAME=VAL or NAME)"
    24   echo "    -v           verbose"
    25   echo
    26   echo "  Build and manage Isabelle sessions, depending on implicit"
    27   echo "  ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\""
    28   echo
    29   echo "  ML_PLATFORM=\"$ML_PLATFORM\""
    30   echo "  ML_HOME=\"$ML_HOME\""
    31   echo "  ML_SYSTEM=\"$ML_SYSTEM\""
    32   echo "  ML_OPTIONS=\"$ML_OPTIONS\""
    33   echo
    34   exit 1
    35 }
    36 
    37 function fail()
    38 {
    39   echo "$1" >&2
    40   exit 2
    41 }
    42 
    43 function check_number()
    44 {
    45   [ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""
    46 }
    47 
    48 
    49 ## process command line
    50 
    51 ALL_SESSIONS=false
    52 BUILD_IMAGES=false
    53 MAX_JOBS=1
    54 LIST_ONLY=false
    55 VERBOSE=false
    56 
    57 declare -a MORE_DIRS=()
    58 eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
    59 
    60 while getopts "abd:j:lo:v" OPT
    61 do
    62   case "$OPT" in
    63     a)
    64       ALL_SESSIONS="true"
    65       ;;
    66     b)
    67       BUILD_IMAGES="true"
    68       ;;
    69     d)
    70       MORE_DIRS["${#MORE_DIRS[@]}"]="$OPTARG"
    71       ;;
    72     j)
    73       check_number "$OPTARG"
    74       MAX_JOBS="$OPTARG"
    75       ;;
    76     l)
    77       LIST_ONLY="true"
    78       ;;
    79     o)
    80       BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
    81       ;;
    82     v)
    83       VERBOSE="true"
    84       ;;
    85     \?)
    86       usage
    87       ;;
    88   esac
    89 done
    90 
    91 shift $(($OPTIND - 1))
    92 
    93 
    94 ## main
    95 
    96 [ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
    97 
    98 exec "$ISABELLE_TOOL" java isabelle.Build \
    99   "$ALL_SESSIONS" "$BUILD_IMAGES" "$MAX_JOBS" "$LIST_ONLY" "$VERBOSE" \
   100   "${MORE_DIRS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@"