Admin/build
author blanchet
Mon, 23 Jul 2012 15:32:30 +0200
changeset 49449 aaaec69db3db
parent 48279 63c05991882e
child 49513 62f183129ae6
permissions -rwxr-xr-x
ensure all calls to "mash" program are synchronous
     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_test       test separate build of jars
    32     jars_fresh      fresh build of jars
    33 
    34 EOF
    35   exit 1
    36 }
    37 
    38 function fail()
    39 {
    40   echo "$1" >&2
    41   exit 2
    42 }
    43 
    44 
    45 ## process command line
    46 
    47 [ "$#" -eq 0 ] && usage
    48 
    49 MODULES="$@"; shift "$#"
    50 
    51 
    52 ## modules
    53 
    54 function build_all ()
    55 {
    56   build_doc
    57   build_browser
    58   build_jars
    59 }
    60 
    61 
    62 function build_browser ()
    63 {
    64   pushd "$ISABELLE_HOME/lib/browser" >/dev/null
    65   "$ISABELLE_TOOL" env ./build || exit $?
    66   popd >/dev/null
    67 }
    68 
    69 
    70 function build_doc ()
    71 {
    72   echo "###"
    73   echo "### Building documentation ..."
    74   echo "###"
    75 
    76   cd "$ISABELLE_HOME/doc-src"
    77   for DOC in $(cat Dirs)
    78   do
    79     pushd "$DOC" >/dev/null
    80     make clean dvi || fail "DVI document for $DOC failed!"
    81     make clean pdf || fail "PDF document for $DOC failed!"
    82     popd >/dev/null
    83   done
    84 }
    85 
    86 
    87 function build_doc-src ()
    88 {
    89   echo "###"
    90   echo "### Building documentation sources..."
    91   echo "###"
    92 
    93   cd "$ISABELLE_HOME/doc-src"
    94   for DOC in $(cat Dirs)
    95   do
    96     pushd "$DOC" >/dev/null
    97     if [[ -f "IsaMakefile" ]]
    98     then
    99       "$ISABELLE_TOOL" make || exit $?
   100     fi
   101     popd >/dev/null
   102   done
   103 }
   104 
   105 
   106 function build_jars ()
   107 {
   108   pushd "$ISABELLE_HOME/src/Pure" >/dev/null
   109   "$ISABELLE_TOOL" env ./build-jars "$@" || exit $?
   110   popd >/dev/null
   111 }
   112 
   113 
   114 ## main
   115 
   116 for MODULE in $MODULES
   117 do
   118   case $MODULE in
   119     all) build_all;;
   120     browser) build_browser;;
   121     doc) build_doc;;
   122     doc-src) build_doc-src;;
   123     jars) build_jars;;
   124     jars_fresh) build_jars -f;;
   125     jars_test) build_jars -t;;
   126     *) fail "Bad module $MODULE"
   127   esac
   128 done