src/Pure/build-jars
author wenzelm
Thu Jun 23 17:17:40 2011 +0200 (2011-06-23)
changeset 43523 5aaa0fe92672
parent 43521 d477b92109b8
child 43600 4ac04bf9ff89
permissions -rwxr-xr-x
simplified arrangement of jars;
     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 # build
   111 
   112 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   113 TARGET="$TARGET_DIR/ext/Pure.jar"
   114 
   115 declare -a UPDATED=()
   116 
   117 if [ -n "$FRESH" ]; then
   118   OUTDATED=true
   119 else
   120   OUTDATED=false
   121   if [ ! -e "$TARGET" ]; then
   122     OUTDATED=true
   123   else
   124     for DEP in "${SOURCES[@]}"
   125     do
   126       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   127       [ "$DEP" -nt "$TARGET" ] && {
   128         OUTDATED=true
   129         UPDATED["${#UPDATED[@]}"]="$DEP"
   130       }
   131     done
   132   fi
   133 fi
   134 
   135 if [ "$OUTDATED" = true ]
   136 then
   137   echo "###"
   138   echo "### Building Isabelle/Scala layer ..."
   139   echo "###"
   140 
   141   [ "${#UPDATED[@]}" -gt 0 ] && {
   142     echo "Changed files:"
   143     for FILE in "${UPDATED[@]}"
   144     do
   145       echo "  $FILE"
   146     done
   147   }
   148 
   149   rm -rf classes && mkdir classes
   150   "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
   151     fail "Failed to compile sources"
   152   mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
   153 
   154   pushd classes >/dev/null
   155 
   156   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   157   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   158   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   159 
   160   jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
   161     fail "Failed to produce $TARGET"
   162 
   163   cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
   164 
   165   popd >/dev/null
   166 
   167   rm -rf classes
   168 fi