src/Pure/build-jars
author wenzelm
Mon Jan 11 23:41:06 2010 +0100 (2010-01-11)
changeset 34876 b52e03f68cc3
parent 34871 e596a0b71f3c
child 36011 3ff725ac13a4
permissions -rwxr-xr-x
clarified terminology;
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@34871
    48
  System/session.scala
wenzelm@34282
    49
  System/session_manager.scala
wenzelm@34282
    50
  System/standard_system.scala
wenzelm@34871
    51
  Thy/change.scala
wenzelm@34871
    52
  Thy/command.scala
wenzelm@34282
    53
  Thy/completion.scala
wenzelm@34871
    54
  Thy/document.scala
wenzelm@34282
    55
  Thy/html.scala
wenzelm@34871
    56
  Thy/markup_node.scala
wenzelm@34871
    57
  Thy/state.scala
wenzelm@34282
    58
  Thy/text_edit.scala
wenzelm@34282
    59
  Thy/thy_header.scala
wenzelm@34282
    60
  Thy/thy_syntax.scala
wenzelm@34282
    61
  library.scala
wenzelm@34282
    62
)
wenzelm@34282
    63
wenzelm@34284
    64
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@34284
    65
PURE_JAR="$TARGET_DIR/Pure.jar"
wenzelm@34284
    66
FULL_JAR="$TARGET_DIR/isabelle-scala.jar"
wenzelm@34284
    67
wenzelm@34284
    68
declare -a TARGETS=("$PURE_JAR" "$FULL_JAR")
wenzelm@34282
    69
wenzelm@34282
    70
wenzelm@34282
    71
## main
wenzelm@34282
    72
wenzelm@34282
    73
OUTDATED=false
wenzelm@34282
    74
wenzelm@34282
    75
for SOURCE in "${SOURCES[@]}"
wenzelm@34282
    76
do
wenzelm@34282
    77
  [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
wenzelm@34284
    78
  for TARGET in "${TARGETS[@]}"
wenzelm@34282
    79
  do
wenzelm@34282
    80
    [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
wenzelm@34282
    81
  done
wenzelm@34282
    82
done
wenzelm@34282
    83
wenzelm@34284
    84
if [ "$OUTDATED" = true ]
wenzelm@34284
    85
then
wenzelm@34282
    86
  echo "###"
wenzelm@34876
    87
  echo "### Building Isabelle/Scala layer ..."
wenzelm@34282
    88
  echo "###"
wenzelm@34282
    89
wenzelm@34282
    90
  rm -rf classes && mkdir classes
wenzelm@34282
    91
  "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target jvm-1.5 "${SOURCES[@]}" || \
wenzelm@34282
    92
    fail "Failed to compile sources"
wenzelm@34284
    93
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
wenzelm@34282
    94
  (
wenzelm@34282
    95
    cd classes
wenzelm@34282
    96
    jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
wenzelm@34282
    97
      fail "Failed to produce $PURE_JAR"
wenzelm@34282
    98
wenzelm@34282
    99
    cp "$SCALA_HOME/lib/scala-swing.jar" .
wenzelm@34282
   100
    jar xf scala-swing.jar
wenzelm@34282
   101
wenzelm@34282
   102
    cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
wenzelm@34282
   103
    jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
wenzelm@34282
   104
      fail "Failed to produce $FULL_JAR"
wenzelm@34282
   105
  )
wenzelm@34282
   106
  rm -rf classes
wenzelm@34282
   107
fi