src/Pure/build-jars
changeset 34284 33ad3571ad83
parent 34282 549969a7f582
child 34871 e596a0b71f3c
equal deleted inserted replaced
34283:7911e83d06c0 34284:33ad3571ad83
       
     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_manager.scala
       
    49   System/standard_system.scala
       
    50   Thy/completion.scala
       
    51   Thy/html.scala
       
    52   Thy/text_edit.scala
       
    53   Thy/thy_header.scala
       
    54   Thy/thy_syntax.scala
       
    55   library.scala
       
    56 )
       
    57 
       
    58 TARGET_DIR="$ISABELLE_HOME/lib/classes"
       
    59 PURE_JAR="$TARGET_DIR/Pure.jar"
       
    60 FULL_JAR="$TARGET_DIR/isabelle-scala.jar"
       
    61 
       
    62 declare -a TARGETS=("$PURE_JAR" "$FULL_JAR")
       
    63 
       
    64 
       
    65 ## main
       
    66 
       
    67 OUTDATED=false
       
    68 
       
    69 for SOURCE in "${SOURCES[@]}"
       
    70 do
       
    71   [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
       
    72   for TARGET in "${TARGETS[@]}"
       
    73   do
       
    74     [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
       
    75   done
       
    76 done
       
    77 
       
    78 if [ "$OUTDATED" = true ]
       
    79 then
       
    80   echo "###"
       
    81   echo "### Building Isabelle/Scala components ..."
       
    82   echo "###"
       
    83 
       
    84   rm -rf classes && mkdir classes
       
    85   "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target jvm-1.5 "${SOURCES[@]}" || \
       
    86     fail "Failed to compile sources"
       
    87   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
       
    88   (
       
    89     cd classes
       
    90     jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
       
    91       fail "Failed to produce $PURE_JAR"
       
    92 
       
    93     cp "$SCALA_HOME/lib/scala-swing.jar" .
       
    94     jar xf scala-swing.jar
       
    95 
       
    96     cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
       
    97     jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
       
    98       fail "Failed to produce $FULL_JAR"
       
    99   )
       
   100   rm -rf classes
       
   101 fi