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