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