Admin/build
author haftmann
Wed Mar 14 15:54:54 2012 +0100 (2012-03-14)
changeset 46933 3b02b0ef8d48
parent 45385 7c1375ba1424
child 47115 1a05adae1cc9
permissions -rwxr-xr-x
doc-src build option (for emerging mira configuration)
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@27628
    28
    doc             documentation (requires latex and rail)
haftmann@46933
    29
    doc-src         documentation sources from Isabelle theories
wenzelm@34876
    30
    jars            Isabelle/Scala layer (requires Scala in \$SCALA_HOME)
wenzelm@43280
    31
    jars_fresh      fresh build of jars
wenzelm@27628
    32
wenzelm@27628
    33
EOF
wenzelm@27628
    34
  exit 1
wenzelm@27628
    35
}
wenzelm@27628
    36
wenzelm@27628
    37
function fail()
wenzelm@27628
    38
{
wenzelm@27628
    39
  echo "$1" >&2
wenzelm@27628
    40
  exit 2
wenzelm@27628
    41
}
wenzelm@27628
    42
wenzelm@27628
    43
wenzelm@27628
    44
## process command line
wenzelm@27628
    45
wenzelm@27628
    46
[ "$#" -eq 0 ] && usage
wenzelm@27628
    47
wenzelm@27628
    48
MODULES="$@"; shift "$#"
wenzelm@27628
    49
wenzelm@27628
    50
wenzelm@27628
    51
## modules
wenzelm@27628
    52
wenzelm@27628
    53
function build_all ()
wenzelm@27628
    54
{
wenzelm@27649
    55
  build_doc
wenzelm@27628
    56
  build_browser
wenzelm@27628
    57
  build_jars
wenzelm@27628
    58
}
wenzelm@27628
    59
wenzelm@27628
    60
wenzelm@27628
    61
function build_browser ()
wenzelm@27628
    62
{
wenzelm@34283
    63
  pushd "$ISABELLE_HOME/lib/browser" >/dev/null
wenzelm@34297
    64
  "$ISABELLE_TOOL" env ./build || exit $?
wenzelm@34283
    65
  popd >/dev/null
wenzelm@27628
    66
}
wenzelm@27628
    67
wenzelm@27628
    68
wenzelm@27628
    69
function build_doc ()
wenzelm@27628
    70
{
wenzelm@27628
    71
  echo "###"
wenzelm@27628
    72
  echo "### Building documentation ..."
wenzelm@27628
    73
  echo "###"
wenzelm@27628
    74
wenzelm@28956
    75
  cd "$ISABELLE_HOME/doc-src"
wenzelm@27628
    76
  for DOC in $(cat Dirs)
wenzelm@27628
    77
  do
wenzelm@27629
    78
    pushd "$DOC" >/dev/null
wenzelm@27628
    79
    make clean dvi || fail "DVI document for $DOC failed!"
wenzelm@27628
    80
    make clean pdf || fail "PDF document for $DOC failed!"
wenzelm@27629
    81
    popd >/dev/null
wenzelm@27628
    82
  done
wenzelm@27628
    83
}
wenzelm@27628
    84
wenzelm@27628
    85
haftmann@46933
    86
function build_doc-src ()
haftmann@46933
    87
{
haftmann@46933
    88
  echo "###"
haftmann@46933
    89
  echo "### Building documentation sources..."
haftmann@46933
    90
  echo "###"
haftmann@46933
    91
haftmann@46933
    92
  cd "$ISABELLE_HOME/doc-src"
haftmann@46933
    93
  for DOC in $(cat Dirs)
haftmann@46933
    94
  do
haftmann@46933
    95
    pushd "$DOC" >/dev/null
haftmann@46933
    96
    if [[ -f "IsaMakefile" ]]
haftmann@46933
    97
    then
haftmann@46933
    98
      "$ISABELLE_TOOL" make || exit $?
haftmann@46933
    99
    fi
haftmann@46933
   100
    popd >/dev/null
haftmann@46933
   101
  done
haftmann@46933
   102
}
haftmann@46933
   103
haftmann@46933
   104
wenzelm@27628
   105
function build_jars ()
wenzelm@27628
   106
{
wenzelm@28956
   107
  pushd "$ISABELLE_HOME/src/Pure" >/dev/null
wenzelm@43280
   108
  "$ISABELLE_TOOL" env ./build-jars "$@" || exit $?
wenzelm@27904
   109
  popd >/dev/null
wenzelm@27628
   110
}
wenzelm@27628
   111
wenzelm@27628
   112
wenzelm@27628
   113
## main
wenzelm@27628
   114
wenzelm@27628
   115
for MODULE in $MODULES
wenzelm@27628
   116
do
wenzelm@27628
   117
  case $MODULE in
wenzelm@27628
   118
    all) build_all;;
wenzelm@27628
   119
    browser) build_browser;;
wenzelm@27628
   120
    doc) build_doc;;
haftmann@46933
   121
    doc-src) build_doc-src;;
wenzelm@27628
   122
    jars) build_jars;;
wenzelm@43280
   123
    jars_fresh) build_jars -f;;
wenzelm@27628
   124
    *) fail "Bad module $MODULE"
wenzelm@27628
   125
  esac
wenzelm@27628
   126
done