src/Pure/mk-jars
author wenzelm
Wed Jan 06 20:00:22 2010 +0100 (2010-01-06)
changeset 34282 549969a7f582
permissions -rwxr-xr-x
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm@34282
     1
#!/usr/bin/env bash
wenzelm@34282
     2
#
wenzelm@34282
     3
# Author: Makarius
wenzelm@34282
     4
#
wenzelm@34282
     5
# mk-jars - build Isabelle/Scala
wenzelm@34282
     6
#
wenzelm@34282
     7
# Requires proper Isabelle settings environment.
wenzelm@34282
     8
wenzelm@34282
     9
wenzelm@34282
    10
## diagnostics
wenzelm@34282
    11
wenzelm@34282
    12
function fail()
wenzelm@34282
    13
{
wenzelm@34282
    14
  echo "$1" >&2
wenzelm@34282
    15
  exit 2
wenzelm@34282
    16
}
wenzelm@34282
    17
wenzelm@34282
    18
[ -n "$ISABELLE_HOME" ] || fail "Missing Isabelle settings environment"
wenzelm@34282
    19
[ -z "$SCALA_HOME" ] && fail "Scala unavailable: unknown SCALA_HOME"
wenzelm@34282
    20
wenzelm@34282
    21
wenzelm@34282
    22
## dependencies
wenzelm@34282
    23
wenzelm@34282
    24
declare -a SOURCES=(
wenzelm@34282
    25
  Concurrent/future.scala
wenzelm@34282
    26
  General/download.scala
wenzelm@34282
    27
  General/event_bus.scala
wenzelm@34282
    28
  General/exn.scala
wenzelm@34282
    29
  General/linear_set.scala
wenzelm@34282
    30
  General/markup.scala
wenzelm@34282
    31
  General/position.scala
wenzelm@34282
    32
  General/scan.scala
wenzelm@34282
    33
  General/swing_thread.scala
wenzelm@34282
    34
  General/symbol.scala
wenzelm@34282
    35
  General/xml.scala
wenzelm@34282
    36
  General/yxml.scala
wenzelm@34282
    37
  Isar/isar_document.scala
wenzelm@34282
    38
  Isar/outer_keyword.scala
wenzelm@34282
    39
  Isar/outer_lex.scala
wenzelm@34282
    40
  Isar/outer_parse.scala
wenzelm@34282
    41
  Isar/outer_syntax.scala
wenzelm@34282
    42
  System/cygwin.scala
wenzelm@34282
    43
  System/gui_setup.scala
wenzelm@34282
    44
  System/isabelle_process.scala
wenzelm@34282
    45
  System/isabelle_syntax.scala
wenzelm@34282
    46
  System/isabelle_system.scala
wenzelm@34282
    47
  System/platform.scala
wenzelm@34282
    48
  System/session_manager.scala
wenzelm@34282
    49
  System/standard_system.scala
wenzelm@34282
    50
  Thy/completion.scala
wenzelm@34282
    51
  Thy/html.scala
wenzelm@34282
    52
  Thy/text_edit.scala
wenzelm@34282
    53
  Thy/thy_header.scala
wenzelm@34282
    54
  Thy/thy_syntax.scala
wenzelm@34282
    55
  library.scala
wenzelm@34282
    56
)
wenzelm@34282
    57
wenzelm@34282
    58
JAR_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@34282
    59
PURE_JAR="$JAR_DIR/Pure.jar"
wenzelm@34282
    60
FULL_JAR="$JAR_DIR/isabelle-scala.jar"
wenzelm@34282
    61
wenzelm@34282
    62
wenzelm@34282
    63
## main
wenzelm@34282
    64
wenzelm@34282
    65
OUTDATED=false
wenzelm@34282
    66
wenzelm@34282
    67
for SOURCE in "${SOURCES[@]}"
wenzelm@34282
    68
do
wenzelm@34282
    69
  [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
wenzelm@34282
    70
  for TARGET in "$PURE_JAR" "$FULL_JAR"
wenzelm@34282
    71
  do
wenzelm@34282
    72
    [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
wenzelm@34282
    73
  done
wenzelm@34282
    74
done
wenzelm@34282
    75
wenzelm@34282
    76
if [ "$OUTDATED" = true ]; then
wenzelm@34282
    77
  echo "###"
wenzelm@34282
    78
  echo "### Building Isabelle/Scala components ..."
wenzelm@34282
    79
  echo "###"
wenzelm@34282
    80
wenzelm@34282
    81
  rm -rf classes && mkdir classes
wenzelm@34282
    82
  "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target jvm-1.5 "${SOURCES[@]}" || \
wenzelm@34282
    83
    fail "Failed to compile sources"
wenzelm@34282
    84
  mkdir -p "$JAR_DIR" || fail "Failed to create directory $JAR_DIR"
wenzelm@34282
    85
  (
wenzelm@34282
    86
    cd classes
wenzelm@34282
    87
    jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
wenzelm@34282
    88
      fail "Failed to produce $PURE_JAR"
wenzelm@34282
    89
wenzelm@34282
    90
    cp "$SCALA_HOME/lib/scala-swing.jar" .
wenzelm@34282
    91
    jar xf scala-swing.jar
wenzelm@34282
    92
wenzelm@34282
    93
    cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
wenzelm@34282
    94
    jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
wenzelm@34282
    95
      fail "Failed to produce $FULL_JAR"
wenzelm@34282
    96
  )
wenzelm@34282
    97
  rm -rf classes
wenzelm@34282
    98
fi