1#!/usr/bin/env bash
2#
3# Administrative build for Isabelle source distribution.
4
5## directory layout
6
7if [ -z "$ISABELLE_HOME" ]; then
8  ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
9  ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
10fi
11
12
13## diagnostics
14
15PRG="$(basename "$0")"
16
17function usage()
18{
19  cat <<EOF
20
21Usage: $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
27    browser         graph browser
28    jars            Isabelle/Scala
29    jars_fresh      fresh build of jars
30
31EOF
32  exit 1
33}
34
35function fail()
36{
37  echo "$1" >&2
38  exit 2
39}
40
41
42## process command line
43
44[ "$#" -eq 0 ] && usage
45
46MODULES="$@"; shift "$#"
47
48
49## modules
50
51function build_all ()
52{
53  build_browser
54  build_jars
55}
56
57
58function build_browser ()
59{
60  pushd "$ISABELLE_HOME/lib/browser" >/dev/null
61  "$ISABELLE_TOOL" env ./build || exit $?
62  popd >/dev/null
63}
64
65
66function build_jars ()
67{
68  pushd "$ISABELLE_HOME/src/Pure" >/dev/null
69  "$ISABELLE_TOOL" env ./build-jars "$@" || exit $?
70  popd >/dev/null
71}
72
73
74## main
75
76#FIXME workarounds for scalac 2.11.0
77export CYGWIN="nodosfilewarning"
78function stty() { :; }
79export -f stty
80
81for MODULE in $MODULES
82do
83  case $MODULE in
84    all) build_all;;
85    browser) build_browser;;
86    jars) build_jars;;
87    jars_fresh) build_jars -f;;
88    *) fail "Bad module $MODULE"
89  esac
90done
91