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