src/Pure/build-jars
author wenzelm
Wed Jun 08 17:11:00 2011 +0200 (2011-06-08)
changeset 43280 e5dd0ae1b054
parent 42899 108e815fdc8e
child 43285 966f359dc724
permissions -rwxr-xr-x
support fresh build of jars;
prefer pushd/popd, to avoid unclarity about fail/exit within sub-shell;
     1 #!/usr/bin/env bash
     2 #
     3 # Author: Makarius
     4 #
     5 # build-jars - build Isabelle/Scala
     6 #
     7 # Requires proper Isabelle settings environment.
     8 
     9 
    10 ## diagnostics
    11 
    12 PRG="$(basename "$0")"
    13 
    14 function usage()
    15 {
    16   echo
    17   echo "Usage: isabelle $PRG [OPTIONS]"
    18   echo
    19   echo "  Options are:"
    20   echo "    -f           fresh build"
    21   echo
    22   exit 1
    23 }
    24 
    25 function fail()
    26 {
    27   echo "$1" >&2
    28   exit 2
    29 }
    30 
    31 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    32 [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
    33 
    34 
    35 ## process command line
    36 
    37 # options
    38 
    39 FRESH=""
    40 
    41 while getopts "f" OPT
    42 do
    43   case "$OPT" in
    44     f)
    45       FRESH=true
    46       ;;
    47     \?)
    48       usage
    49       ;;
    50   esac
    51 done
    52 
    53 shift $(($OPTIND - 1))
    54 
    55 
    56 # args
    57 
    58 [ "$#" -ne 0 ] && usage
    59 
    60 
    61 
    62 ## dependencies
    63 
    64 declare -a SOURCES=(
    65   Concurrent/future.scala
    66   Concurrent/simple_thread.scala
    67   Concurrent/volatile.scala
    68   General/exn.scala
    69   General/timing.scala
    70   General/linear_set.scala
    71   General/markup.scala
    72   General/position.scala
    73   General/pretty.scala
    74   General/scan.scala
    75   General/sha1.scala
    76   General/symbol.scala
    77   General/xml.scala
    78   General/xml_data.scala
    79   General/yxml.scala
    80   Isar/keyword.scala
    81   Isar/outer_syntax.scala
    82   Isar/parse.scala
    83   Isar/token.scala
    84   PIDE/command.scala
    85   PIDE/document.scala
    86   PIDE/isar_document.scala
    87   PIDE/markup_tree.scala
    88   PIDE/text.scala
    89   System/cygwin.scala
    90   System/download.scala
    91   System/event_bus.scala
    92   System/gui_setup.scala
    93   System/isabelle_process.scala
    94   System/isabelle_syntax.scala
    95   System/isabelle_system.scala
    96   System/platform.scala
    97   System/session.scala
    98   System/session_manager.scala
    99   System/standard_system.scala
   100   System/swing_thread.scala
   101   Thy/completion.scala
   102   Thy/html.scala
   103   Thy/thy_header.scala
   104   Thy/thy_syntax.scala
   105   library.scala
   106   package.scala
   107 )
   108 
   109 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   110 PURE_JAR="$TARGET_DIR/Pure.jar"
   111 FULL_JAR="$TARGET_DIR/isabelle-scala.jar"
   112 
   113 declare -a TARGETS=("$PURE_JAR" "$FULL_JAR")
   114 
   115 
   116 ## main
   117 
   118 if [ -n "$FRESH" ]; then
   119   OUTDATED=true
   120 else
   121   OUTDATED=false
   122   for SOURCE in "${SOURCES[@]}"
   123   do
   124     [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
   125     for TARGET in "${TARGETS[@]}"
   126     do
   127       [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
   128     done
   129   done
   130 fi
   131 
   132 if [ "$OUTDATED" = true ]
   133 then
   134   echo "###"
   135   echo "### Building Isabelle/Scala layer ..."
   136   echo "###"
   137 
   138   rm -rf classes && mkdir classes
   139   "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
   140     fail "Failed to compile sources"
   141   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   142 
   143   pushd classes
   144 
   145   jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
   146     fail "Failed to produce $PURE_JAR"
   147 
   148   cp "$SCALA_HOME/lib/scala-swing.jar" .
   149   jar xf scala-swing.jar
   150 
   151   cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
   152   jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
   153     fail "Failed to produce $FULL_JAR"
   154 
   155   popd >/dev/null
   156 
   157   rm -rf classes
   158 fi