src/Pure/build-jars
author wenzelm
Thu, 23 Jun 2011 10:58:29 +0200
changeset 44397 87ec9a1c0f98
parent 44277 723a8af9d3f0
child 44401 d477b92109b8
permissions -rwxr-xr-x
basic setup for Isabelle charset;
     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_charset.scala
    41   System/isabelle_process.scala
    42   System/isabelle_syntax.scala
    43   System/isabelle_system.scala
    44   System/platform.scala
    45   System/session.scala
    46   System/session_manager.scala
    47   System/standard_system.scala
    48   System/swing_thread.scala
    49   Thy/completion.scala
    50   Thy/html.scala
    51   Thy/thy_header.scala
    52   Thy/thy_syntax.scala
    53   library.scala
    54   package.scala
    55 )
    56 
    57 
    58 ## diagnostics
    59 
    60 PRG="$(basename "$0")"
    61 
    62 function usage()
    63 {
    64   echo
    65   echo "Usage: isabelle $PRG [OPTIONS]"
    66   echo
    67   echo "  Options are:"
    68   echo "    -f           fresh build"
    69   echo
    70   exit 1
    71 }
    72 
    73 function fail()
    74 {
    75   echo "$1" >&2
    76   exit 2
    77 }
    78 
    79 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    80 [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
    81 
    82 
    83 ## process command line
    84 
    85 # options
    86 
    87 FRESH=""
    88 
    89 while getopts "f" OPT
    90 do
    91   case "$OPT" in
    92     f)
    93       FRESH=true
    94       ;;
    95     \?)
    96       usage
    97       ;;
    98   esac
    99 done
   100 
   101 shift $(($OPTIND - 1))
   102 
   103 
   104 # args
   105 
   106 [ "$#" -ne 0 ] && usage
   107 
   108 
   109 
   110 ## dependencies
   111 
   112 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   113 PURE_JAR="$TARGET_DIR/Pure.jar"
   114 FULL_JAR="$TARGET_DIR/isabelle-scala.jar"
   115 
   116 declare -a TARGETS=("$PURE_JAR" "$FULL_JAR")
   117 
   118 
   119 ## main
   120 
   121 declare -a UPDATED=()
   122 
   123 if [ -n "$FRESH" ]; then
   124   OUTDATED=true
   125 else
   126   OUTDATED=false
   127   for TARGET in "${TARGETS[@]}"
   128   do
   129     [ ! -e "$TARGET" ] && OUTDATED=true
   130   done
   131   if [ "$OUTDATED" = false ]; then
   132     for DEP in "${SOURCES[@]}"
   133     do
   134       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   135       UPDATE=""
   136       for TARGET in "${TARGETS[@]}"
   137       do
   138         [ "$DEP" -nt "$TARGET" ] && {
   139           OUTDATED=true
   140           UPDATE=true
   141         }
   142       done
   143       [ -n "$UPDATE" ] && UPDATED["${#UPDATED[@]}"]="$DEP"
   144     done
   145   fi
   146 fi
   147 
   148 if [ "$OUTDATED" = true ]
   149 then
   150   echo "###"
   151   echo "### Building Isabelle/Scala layer ..."
   152   echo "###"
   153 
   154   [ "${#UPDATED[@]}" -gt 0 ] && {
   155     echo "Changed files:"
   156     for FILE in "${UPDATED[@]}"
   157     do
   158       echo "  $FILE"
   159     done
   160   }
   161 
   162   rm -rf classes && mkdir classes
   163   "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
   164     fail "Failed to compile sources"
   165   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   166 
   167   pushd classes >/dev/null
   168 
   169   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   170   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   171   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   172 
   173   jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup META-INF isabelle || \
   174     fail "Failed to produce $PURE_JAR"
   175 
   176   cp "$SCALA_HOME/lib/scala-swing.jar" .
   177   jar xf scala-swing.jar
   178 
   179   cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
   180   jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
   181     fail "Failed to produce $FULL_JAR"
   182 
   183   popd >/dev/null
   184 
   185   rm -rf classes
   186 fi