src/Pure/build-jars
author wenzelm
Sat Aug 28 17:20:53 2010 +0200 (2010-08-28)
changeset 38840 ec75dc58688b
parent 38636 b7647ca7de5a
child 40393 2bb7ec08574a
permissions -rwxr-xr-x
volatile variables (in Scala);
     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 "Unknown SCALA_HOME -- Scala unavailable"
    20 
    21 
    22 ## dependencies
    23 
    24 declare -a SOURCES=(
    25   Concurrent/future.scala
    26   Concurrent/simple_thread.scala
    27   Concurrent/volatile.scala
    28   General/exn.scala
    29   General/linear_set.scala
    30   General/markup.scala
    31   General/position.scala
    32   General/pretty.scala
    33   General/scan.scala
    34   General/sha1.scala
    35   General/symbol.scala
    36   General/xml.scala
    37   General/xml_data.scala
    38   General/yxml.scala
    39   Isar/keyword.scala
    40   Isar/outer_syntax.scala
    41   Isar/parse.scala
    42   Isar/token.scala
    43   PIDE/command.scala
    44   PIDE/document.scala
    45   PIDE/isar_document.scala
    46   PIDE/markup_tree.scala
    47   PIDE/text.scala
    48   System/cygwin.scala
    49   System/download.scala
    50   System/event_bus.scala
    51   System/gui_setup.scala
    52   System/isabelle_process.scala
    53   System/isabelle_syntax.scala
    54   System/isabelle_system.scala
    55   System/platform.scala
    56   System/session.scala
    57   System/session_manager.scala
    58   System/standard_system.scala
    59   System/swing_thread.scala
    60   Thy/completion.scala
    61   Thy/html.scala
    62   Thy/thy_header.scala
    63   Thy/thy_syntax.scala
    64   library.scala
    65 )
    66 
    67 TARGET_DIR="$ISABELLE_HOME/lib/classes"
    68 PURE_JAR="$TARGET_DIR/Pure.jar"
    69 FULL_JAR="$TARGET_DIR/isabelle-scala.jar"
    70 
    71 declare -a TARGETS=("$PURE_JAR" "$FULL_JAR")
    72 
    73 
    74 ## main
    75 
    76 OUTDATED=false
    77 
    78 for SOURCE in "${SOURCES[@]}"
    79 do
    80   [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
    81   for TARGET in "${TARGETS[@]}"
    82   do
    83     [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
    84   done
    85 done
    86 
    87 if [ "$OUTDATED" = true ]
    88 then
    89   echo "###"
    90   echo "### Building Isabelle/Scala layer ..."
    91   echo "###"
    92 
    93   rm -rf classes && mkdir classes
    94   "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
    95     fail "Failed to compile sources"
    96   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
    97   (
    98     cd classes
    99     jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
   100       fail "Failed to produce $PURE_JAR"
   101 
   102     cp "$SCALA_HOME/lib/scala-swing.jar" .
   103     jar xf scala-swing.jar
   104 
   105     cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
   106     jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
   107       fail "Failed to produce $FULL_JAR"
   108   )
   109   rm -rf classes
   110 fi