lib/Tools/build
author wenzelm
Tue Jul 24 10:39:03 2012 +0200 (2012-07-24)
changeset 48459 375e45df6fdf
parent 48447 ef600ce4559c
child 48469 826a771cff33
permissions -rwxr-xr-x
timing is command line options, not system option;
     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 "    -s           system build mode: produce output in ISABELLE_HOME"
    25   echo "    -t           inner session timing"
    26   echo "    -v           verbose"
    27   echo
    28   echo "  Build and manage Isabelle sessions, depending on implicit"
    29   echo "  ISABELLE_BUILD_OPTIONS=\"$ISABELLE_BUILD_OPTIONS\""
    30   echo
    31   echo "  ML_PLATFORM=\"$ML_PLATFORM\""
    32   echo "  ML_HOME=\"$ML_HOME\""
    33   echo "  ML_SYSTEM=\"$ML_SYSTEM\""
    34   echo "  ML_OPTIONS=\"$ML_OPTIONS\""
    35   echo
    36   exit 1
    37 }
    38 
    39 function fail()
    40 {
    41   echo "$1" >&2
    42   exit 2
    43 }
    44 
    45 function check_number()
    46 {
    47   [ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""
    48 }
    49 
    50 
    51 ## process command line
    52 
    53 ALL_SESSIONS=false
    54 BUILD_IMAGES=false
    55 MAX_JOBS=1
    56 LIST_ONLY=false
    57 SYSTEM_MODE=false
    58 TIMING=false
    59 VERBOSE=false
    60 
    61 declare -a MORE_DIRS=()
    62 eval "declare -a BUILD_OPTIONS=($ISABELLE_BUILD_OPTIONS)"
    63 
    64 while getopts "abd:j:lo:stv" OPT
    65 do
    66   case "$OPT" in
    67     a)
    68       ALL_SESSIONS="true"
    69       ;;
    70     b)
    71       BUILD_IMAGES="true"
    72       ;;
    73     d)
    74       MORE_DIRS["${#MORE_DIRS[@]}"]="$OPTARG"
    75       ;;
    76     j)
    77       check_number "$OPTARG"
    78       MAX_JOBS="$OPTARG"
    79       ;;
    80     l)
    81       LIST_ONLY="true"
    82       ;;
    83     o)
    84       BUILD_OPTIONS["${#BUILD_OPTIONS[@]}"]="$OPTARG"
    85       ;;
    86     s)
    87       SYSTEM_MODE="true"
    88       ;;
    89     t)
    90       TIMING="true"
    91       ;;
    92     v)
    93       VERBOSE="true"
    94       ;;
    95     \?)
    96       usage
    97       ;;
    98   esac
    99 done
   100 
   101 shift $(($OPTIND - 1))
   102 
   103 
   104 ## main
   105 
   106 [ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
   107 
   108 exec "$ISABELLE_TOOL" java isabelle.Build \
   109   "$ALL_SESSIONS" "$BUILD_IMAGES" "$MAX_JOBS" "$LIST_ONLY" "$SYSTEM_MODE" "$TIMING" \
   110   "$VERBOSE" "${MORE_DIRS[@]}" $'\n' "${BUILD_OPTIONS[@]}" $'\n' "$@"