src/Pure/build-jars
author wenzelm
Thu May 24 22:49:39 2012 +0200 (2012-05-24)
changeset 47995 72f52cd7c633
parent 47849 48b52cdc214a
child 47997 0a43fc778cd2
permissions -rwxr-xr-x
include scala-compiler.jar in basic Isabelle/Scala environment, to make Isabelle/jEdit console work with scala-2.10.0-M3;
     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/counter.scala
    13   Concurrent/future.scala
    14   Concurrent/simple_thread.scala
    15   Concurrent/volatile.scala
    16   General/exn.scala
    17   General/graph.scala
    18   General/linear_set.scala
    19   General/path.scala
    20   General/position.scala
    21   General/pretty.scala
    22   General/properties.scala
    23   General/scan.scala
    24   General/sha1.scala
    25   General/symbol.scala
    26   General/time.scala
    27   General/timing.scala
    28   Isar/keyword.scala
    29   Isar/outer_syntax.scala
    30   Isar/parse.scala
    31   Isar/token.scala
    32   PIDE/blob.scala
    33   PIDE/command.scala
    34   PIDE/document.scala
    35   PIDE/isabelle_markup.scala
    36   PIDE/markup.scala
    37   PIDE/markup_tree.scala
    38   PIDE/protocol.scala
    39   PIDE/text.scala
    40   PIDE/xml.scala
    41   PIDE/yxml.scala
    42   System/cygwin.scala
    43   System/download.scala
    44   System/event_bus.scala
    45   System/gui_setup.scala
    46   System/invoke_scala.scala
    47   System/isabelle_charset.scala
    48   System/isabelle_process.scala
    49   System/isabelle_system.scala
    50   System/main.scala
    51   System/platform.scala
    52   System/session.scala
    53   System/session_manager.scala
    54   System/standard_system.scala
    55   System/swing_thread.scala
    56   System/system_channel.scala
    57   Thy/completion.scala
    58   Thy/html.scala
    59   Thy/thy_header.scala
    60   Thy/thy_info.scala
    61   Thy/thy_load.scala
    62   Thy/thy_syntax.scala
    63   library.scala
    64   package.scala
    65   term.scala
    66   term_xml.scala
    67 )
    68 
    69 
    70 ## diagnostics
    71 
    72 PRG="$(basename "$0")"
    73 
    74 function usage()
    75 {
    76   echo
    77   echo "Usage: isabelle $PRG [OPTIONS]"
    78   echo
    79   echo "  Options are:"
    80   echo "    -f           fresh build"
    81   echo "    -t           test separate compilation of PIDE"
    82   echo
    83   exit 1
    84 }
    85 
    86 function fail()
    87 {
    88   echo "$1" >&2
    89   exit 2
    90 }
    91 
    92 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    93 
    94 
    95 ## process command line
    96 
    97 # options
    98 
    99 FRESH=""
   100 TEST_PIDE=""
   101 
   102 while getopts "ft" OPT
   103 do
   104   case "$OPT" in
   105     f)
   106       FRESH=true
   107       ;;
   108     t)
   109       TEST_PIDE=true
   110       ;;
   111     \?)
   112       usage
   113       ;;
   114   esac
   115 done
   116 
   117 shift $(($OPTIND - 1))
   118 
   119 
   120 # args
   121 
   122 [ "$#" -ne 0 ] && usage
   123 
   124 
   125 
   126 # build
   127 
   128 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   129 TARGET="$TARGET_DIR/ext/Pure.jar"
   130 
   131 declare -a PIDE_SOURCES=()
   132 declare -a PURE_SOURCES=()
   133 
   134 for DEP in "${SOURCES[@]}"
   135 do
   136   if grep "Module:.*PIDE" "$DEP" >/dev/null
   137   then
   138     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   139   else
   140     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   141   fi
   142 done
   143 
   144 declare -a UPDATED=()
   145 
   146 if [ -n "$FRESH" ]; then
   147   OUTDATED=true
   148 else
   149   OUTDATED=false
   150   if [ ! -e "$TARGET" ]; then
   151     OUTDATED=true
   152   else
   153     for DEP in "${SOURCES[@]}"
   154     do
   155       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   156       [ "$DEP" -nt "$TARGET" ] && {
   157         OUTDATED=true
   158         UPDATED["${#UPDATED[@]}"]="$DEP"
   159       }
   160     done
   161   fi
   162 fi
   163 
   164 if [ "$OUTDATED" = true ]
   165 then
   166   echo "### Building Isabelle/Scala layer ..."
   167 
   168   [ "${#UPDATED[@]}" -gt 0 ] && {
   169     echo "Changed files:"
   170     for FILE in "${UPDATED[@]}"
   171     do
   172       echo "  $FILE"
   173     done
   174   }
   175 
   176   rm -rf classes && mkdir classes
   177 
   178   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   179 
   180   if [ "$TEST_PIDE" = true ]; then
   181     isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   182       fail "Failed to compile PIDE sources"
   183     isabelle_scala scalac $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
   184       fail "Failed to compile Pure sources"
   185   else
   186     isabelle_scala scalac $SCALAC_OPTIONS -classpath classes \
   187       "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   188       fail "Failed to compile sources"
   189   fi
   190 
   191   mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
   192 
   193   pushd classes >/dev/null
   194 
   195   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   196   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   197   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   198 
   199   isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
   200     fail "Failed to produce $TARGET"
   201 
   202   cp "$SCALA_HOME/lib/scala-compiler.jar" \
   203     "$SCALA_HOME/lib/scala-library.jar" \
   204     "$SCALA_HOME/lib/scala-swing.jar" "$TARGET_DIR/ext"
   205 
   206   [ -e "$SCALA_HOME/lib/scala-actors.jar" ] && \
   207     cp "$SCALA_HOME/lib/scala-actors.jar" "$TARGET_DIR/ext"
   208 
   209   popd >/dev/null
   210 
   211   rm -rf classes
   212 fi