| author | wenzelm | 
| Tue, 21 Feb 2012 20:22:23 +0100 | |
| changeset 46579 | fa035a015ea8 | 
| parent 45709 | 87017fcbad83 | 
| child 46611 | 669601fa1a62 | 
| permissions | -rwxr-xr-x | 
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 1 | #!/usr/bin/env bash | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 2 | # | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 3 | # Author: Makarius | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 4 | # | 
| 42899 | 5 | # build-jars - build Isabelle/Scala | 
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 6 | # | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 7 | # Requires proper Isabelle settings environment. | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 8 | |
| 43320 | 9 | ## sources | 
| 10 | ||
| 11 | declare -a SOURCES=( | |
| 43660 | 12 | Concurrent/counter.scala | 
| 43320 | 13 | Concurrent/future.scala | 
| 14 | Concurrent/simple_thread.scala | |
| 15 | Concurrent/volatile.scala | |
| 16 | General/exn.scala | |
| 17 | General/linear_set.scala | |
| 43600 
4ac04bf9ff89
abstract algebra of file paths in Scala (cf. path.ML);
 wenzelm parents: 
43523diff
changeset | 18 | General/path.scala | 
| 43320 | 19 | General/position.scala | 
| 20 | General/pretty.scala | |
| 43780 | 21 | General/properties.scala | 
| 43320 | 22 | General/scan.scala | 
| 23 | General/sha1.scala | |
| 24 | General/symbol.scala | |
| 45674 | 25 | General/time.scala | 
| 45666 | 26 | General/timing.scala | 
| 43320 | 27 | Isar/keyword.scala | 
| 28 | Isar/outer_syntax.scala | |
| 29 | Isar/parse.scala | |
| 30 | Isar/token.scala | |
| 43715 
518e44a0ee15
some support for blobs (arbitrary text files) within document nodes;
 wenzelm parents: 
43695diff
changeset | 31 | PIDE/blob.scala | 
| 43320 | 32 | PIDE/command.scala | 
| 33 | PIDE/document.scala | |
| 45670 | 34 | PIDE/isabelle_markup.scala | 
| 35 | PIDE/markup.scala | |
| 43320 | 36 | PIDE/markup_tree.scala | 
| 45709 
87017fcbad83
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
 wenzelm parents: 
45674diff
changeset | 37 | PIDE/protocol.scala | 
| 43320 | 38 | PIDE/text.scala | 
| 44698 | 39 | PIDE/xml.scala | 
| 40 | PIDE/yxml.scala | |
| 43320 | 41 | System/cygwin.scala | 
| 42 | System/download.scala | |
| 43 | System/event_bus.scala | |
| 44 | System/gui_setup.scala | |
| 43744 
2c7e1565b4a3
some support to invoke Scala methods under program control;
 wenzelm parents: 
43730diff
changeset | 45 | System/invoke_scala.scala | 
| 43517 | 46 | System/isabelle_charset.scala | 
| 43320 | 47 | System/isabelle_process.scala | 
| 48 | System/isabelle_system.scala | |
| 49 | System/platform.scala | |
| 50 | System/session.scala | |
| 51 | System/session_manager.scala | |
| 52 | System/standard_system.scala | |
| 53 | System/swing_thread.scala | |
| 45027 
f459e93a038e
more abstract wrapping of fifos as System_Channel;
 wenzelm parents: 
44698diff
changeset | 54 | System/system_channel.scala | 
| 43320 | 55 | Thy/completion.scala | 
| 56 | Thy/html.scala | |
| 57 | Thy/thy_header.scala | |
| 43651 
511df47bcadc
some support for theory files within Isabelle/Scala session;
 wenzelm parents: 
43600diff
changeset | 58 | Thy/thy_info.scala | 
| 
511df47bcadc
some support for theory files within Isabelle/Scala session;
 wenzelm parents: 
43600diff
changeset | 59 | Thy/thy_load.scala | 
| 43320 | 60 | Thy/thy_syntax.scala | 
| 61 | library.scala | |
| 62 | package.scala | |
| 43730 
a0ed7bc688b5
lambda terms with XML data representation in Scala;
 wenzelm parents: 
43715diff
changeset | 63 | term.scala | 
| 43779 | 64 | term_xml.scala | 
| 43320 | 65 | ) | 
| 66 | ||
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 67 | |
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 68 | ## diagnostics | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 69 | |
| 43280 | 70 | PRG="$(basename "$0")" | 
| 71 | ||
| 72 | function usage() | |
| 73 | {
 | |
| 74 | echo | |
| 75 | echo "Usage: isabelle $PRG [OPTIONS]" | |
| 76 | echo | |
| 77 | echo " Options are:" | |
| 78 | echo " -f fresh build" | |
| 79 | echo | |
| 80 | exit 1 | |
| 81 | } | |
| 82 | ||
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 83 | function fail() | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 84 | {
 | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 85 | echo "$1" >&2 | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 86 | exit 2 | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 87 | } | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 88 | |
| 42899 | 89 | [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment" | 
| 37174 
6feaab4fc27d
assume given SCALA_HOME, e.g. from component settings or external setup;
 wenzelm parents: 
37044diff
changeset | 90 | [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable" | 
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 91 | |
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 92 | |
| 43280 | 93 | ## process command line | 
| 94 | ||
| 95 | # options | |
| 96 | ||
| 97 | FRESH="" | |
| 98 | ||
| 99 | while getopts "f" OPT | |
| 100 | do | |
| 101 | case "$OPT" in | |
| 102 | f) | |
| 103 | FRESH=true | |
| 104 | ;; | |
| 105 | \?) | |
| 106 | usage | |
| 107 | ;; | |
| 108 | esac | |
| 109 | done | |
| 110 | ||
| 111 | shift $(($OPTIND - 1)) | |
| 112 | ||
| 113 | ||
| 114 | # args | |
| 115 | ||
| 116 | [ "$#" -ne 0 ] && usage | |
| 117 | ||
| 118 | ||
| 119 | ||
| 43523 | 120 | # build | 
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 121 | |
| 34284 | 122 | TARGET_DIR="$ISABELLE_HOME/lib/classes" | 
| 43523 | 123 | TARGET="$TARGET_DIR/ext/Pure.jar" | 
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 124 | |
| 45673 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 125 | declare -a PIDE_SOURCES=() | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 126 | declare -a PURE_SOURCES=() | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 127 | |
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 128 | for DEP in "${SOURCES[@]}"
 | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 129 | do | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 130 | if grep "Module:.*PIDE" "$DEP" >/dev/null | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 131 | then | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 132 |     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
 | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 133 | else | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 134 |     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
 | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 135 | fi | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 136 | done | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 137 | |
| 43405 | 138 | declare -a UPDATED=() | 
| 139 | ||
| 43280 | 140 | if [ -n "$FRESH" ]; then | 
| 141 | OUTDATED=true | |
| 142 | else | |
| 143 | OUTDATED=false | |
| 43523 | 144 | if [ ! -e "$TARGET" ]; then | 
| 145 | OUTDATED=true | |
| 146 | else | |
| 43405 | 147 |     for DEP in "${SOURCES[@]}"
 | 
| 43280 | 148 | do | 
| 43405 | 149 | [ ! -e "$DEP" ] && fail "Missing file: $DEP" | 
| 43523 | 150 |       [ "$DEP" -nt "$TARGET" ] && {
 | 
| 151 | OUTDATED=true | |
| 152 |         UPDATED["${#UPDATED[@]}"]="$DEP"
 | |
| 153 | } | |
| 43280 | 154 | done | 
| 43405 | 155 | fi | 
| 43280 | 156 | fi | 
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 157 | |
| 34284 | 158 | if [ "$OUTDATED" = true ] | 
| 159 | then | |
| 34876 | 160 | echo "### Building Isabelle/Scala layer ..." | 
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 161 | |
| 43405 | 162 |   [ "${#UPDATED[@]}" -gt 0 ] && {
 | 
| 163 | echo "Changed files:" | |
| 164 |     for FILE in "${UPDATED[@]}"
 | |
| 165 | do | |
| 166 | echo " $FILE" | |
| 167 | done | |
| 168 | } | |
| 169 | ||
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 170 | rm -rf classes && mkdir classes | 
| 45673 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 171 | |
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 172 | SCALAC_OPTIONS="-unchecked -deprecation -d classes -target:jvm-1.5" | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 173 | |
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 174 |   "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
 | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 175 | fail "Failed to compile PIDE sources" | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 176 | |
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 177 |   "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
 | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 178 | fail "Failed to compile Pure sources" | 
| 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45672diff
changeset | 179 | |
| 43523 | 180 | mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext" | 
| 43280 | 181 | |
| 43285 | 182 | pushd classes >/dev/null | 
| 43280 | 183 | |
| 43517 | 184 | CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider" | 
| 185 | mkdir -p "$(dirname "$CHARSET_SERVICE")" | |
| 186 | echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE" | |
| 187 | ||
| 43523 | 188 | jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \ | 
| 189 | fail "Failed to produce $TARGET" | |
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 190 | |
| 43523 | 191 | cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext" | 
| 43521 
d477b92109b8
provide Isabelle/Scala environment as Java extension, instead of user classpath
 wenzelm parents: 
43517diff
changeset | 192 | |
| 43280 | 193 | popd >/dev/null | 
| 194 | ||
| 34282 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 195 | rm -rf classes | 
| 
549969a7f582
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
 wenzelm parents: diff
changeset | 196 | fi |