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