Admin/build
author wenzelm
Mon Mar 26 16:25:08 2012 +0200 (2012-03-26)
changeset 47115 1a05adae1cc9
parent 46933 3b02b0ef8d48
child 47408 63c05991882e
permissions -rwxr-xr-x
more robust command invocation via ISABELLE_JDK_HOME or SCALA_HOME (NB: bash exec requires genuine executable, not function);
     1 #!/usr/bin/env bash
     2 #
     3 # Administrative build for Isabelle source distribution.
     4 
     5 ## directory layout
     6 
     7 if [ -z "$ISABELLE_HOME" ]; then
     8   ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
     9   ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
    10 fi
    11 
    12 
    13 ## diagnostics
    14 
    15 PRG="$(basename "$0")"
    16 
    17 function usage()
    18 {
    19   cat <<EOF
    20 
    21 Usage: $PRG [MODULES]
    22 
    23   Produce Isabelle distribution modules from current repository sources.
    24   The MODULES list may contain any of the following:
    25 
    26     all             all modules below *except* doc-src
    27     browser         graph browser (requires jdk)
    28     doc             documentation (requires latex and rail)
    29     doc-src         documentation sources from Isabelle theories
    30     jars            Isabelle/Scala layer (requires \$ISABELLE_JDK_HOME and \$SCALA_HOME)
    31     jars_fresh      fresh build of jars
    32 
    33 EOF
    34   exit 1
    35 }
    36 
    37 function fail()
    38 {
    39   echo "$1" >&2
    40   exit 2
    41 }
    42 
    43 
    44 ## process command line
    45 
    46 [ "$#" -eq 0 ] && usage
    47 
    48 MODULES="$@"; shift "$#"
    49 
    50 
    51 ## modules
    52 
    53 function build_all ()
    54 {
    55   build_doc
    56   build_browser
    57   build_jars
    58 }
    59 
    60 
    61 function build_browser ()
    62 {
    63   pushd "$ISABELLE_HOME/lib/browser" >/dev/null
    64   "$ISABELLE_TOOL" env ./build || exit $?
    65   popd >/dev/null
    66 }
    67 
    68 
    69 function build_doc ()
    70 {
    71   echo "###"
    72   echo "### Building documentation ..."
    73   echo "###"
    74 
    75   cd "$ISABELLE_HOME/doc-src"
    76   for DOC in $(cat Dirs)
    77   do
    78     pushd "$DOC" >/dev/null
    79     make clean dvi || fail "DVI document for $DOC failed!"
    80     make clean pdf || fail "PDF document for $DOC failed!"
    81     popd >/dev/null
    82   done
    83 }
    84 
    85 
    86 function build_doc-src ()
    87 {
    88   echo "###"
    89   echo "### Building documentation sources..."
    90   echo "###"
    91 
    92   cd "$ISABELLE_HOME/doc-src"
    93   for DOC in $(cat Dirs)
    94   do
    95     pushd "$DOC" >/dev/null
    96     if [[ -f "IsaMakefile" ]]
    97     then
    98       "$ISABELLE_TOOL" make || exit $?
    99     fi
   100     popd >/dev/null
   101   done
   102 }
   103 
   104 
   105 function build_jars ()
   106 {
   107   pushd "$ISABELLE_HOME/src/Pure" >/dev/null
   108   "$ISABELLE_TOOL" env ./build-jars "$@" || exit $?
   109   popd >/dev/null
   110 }
   111 
   112 
   113 ## main
   114 
   115 for MODULE in $MODULES
   116 do
   117   case $MODULE in
   118     all) build_all;;
   119     browser) build_browser;;
   120     doc) build_doc;;
   121     doc-src) build_doc-src;;
   122     jars) build_jars;;
   123     jars_fresh) build_jars -f;;
   124     *) fail "Bad module $MODULE"
   125   esac
   126 done