src/Pure/build-jars
author wenzelm
Thu Jul 07 13:48:30 2011 +0200 (2011-07-07)
changeset 43695 5130dfe1b7be
parent 43660 bfc0bb115fa1
child 43715 518e44a0ee15
permissions -rwxr-xr-x
simplified Symbol based on lazy Symbol.Interpretation -- reduced odd "functorial style";
tuned implicit build/init messages;
     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/timing.scala
    18   General/linear_set.scala
    19   General/markup.scala
    20   General/path.scala
    21   General/position.scala
    22   General/pretty.scala
    23   General/scan.scala
    24   General/sha1.scala
    25   General/symbol.scala
    26   General/xml.scala
    27   General/xml_data.scala
    28   General/yxml.scala
    29   Isar/keyword.scala
    30   Isar/outer_syntax.scala
    31   Isar/parse.scala
    32   Isar/token.scala
    33   PIDE/command.scala
    34   PIDE/document.scala
    35   PIDE/isar_document.scala
    36   PIDE/markup_tree.scala
    37   PIDE/text.scala
    38   System/cygwin.scala
    39   System/download.scala
    40   System/event_bus.scala
    41   System/gui_setup.scala
    42   System/isabelle_charset.scala
    43   System/isabelle_process.scala
    44   System/isabelle_syntax.scala
    45   System/isabelle_system.scala
    46   System/platform.scala
    47   System/session.scala
    48   System/session_manager.scala
    49   System/standard_system.scala
    50   System/swing_thread.scala
    51   Thy/completion.scala
    52   Thy/html.scala
    53   Thy/thy_header.scala
    54   Thy/thy_info.scala
    55   Thy/thy_load.scala
    56   Thy/thy_syntax.scala
    57   library.scala
    58   package.scala
    59 )
    60 
    61 
    62 ## diagnostics
    63 
    64 PRG="$(basename "$0")"
    65 
    66 function usage()
    67 {
    68   echo
    69   echo "Usage: isabelle $PRG [OPTIONS]"
    70   echo
    71   echo "  Options are:"
    72   echo "    -f           fresh build"
    73   echo
    74   exit 1
    75 }
    76 
    77 function fail()
    78 {
    79   echo "$1" >&2
    80   exit 2
    81 }
    82 
    83 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    84 [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
    85 
    86 
    87 ## process command line
    88 
    89 # options
    90 
    91 FRESH=""
    92 
    93 while getopts "f" OPT
    94 do
    95   case "$OPT" in
    96     f)
    97       FRESH=true
    98       ;;
    99     \?)
   100       usage
   101       ;;
   102   esac
   103 done
   104 
   105 shift $(($OPTIND - 1))
   106 
   107 
   108 # args
   109 
   110 [ "$#" -ne 0 ] && usage
   111 
   112 
   113 
   114 # build
   115 
   116 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   117 TARGET="$TARGET_DIR/ext/Pure.jar"
   118 
   119 declare -a UPDATED=()
   120 
   121 if [ -n "$FRESH" ]; then
   122   OUTDATED=true
   123 else
   124   OUTDATED=false
   125   if [ ! -e "$TARGET" ]; then
   126     OUTDATED=true
   127   else
   128     for DEP in "${SOURCES[@]}"
   129     do
   130       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   131       [ "$DEP" -nt "$TARGET" ] && {
   132         OUTDATED=true
   133         UPDATED["${#UPDATED[@]}"]="$DEP"
   134       }
   135     done
   136   fi
   137 fi
   138 
   139 if [ "$OUTDATED" = true ]
   140 then
   141   echo "### Building Isabelle/Scala layer ..."
   142 
   143   [ "${#UPDATED[@]}" -gt 0 ] && {
   144     echo "Changed files:"
   145     for FILE in "${UPDATED[@]}"
   146     do
   147       echo "  $FILE"
   148     done
   149   }
   150 
   151   rm -rf classes && mkdir classes
   152   "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
   153     fail "Failed to compile sources"
   154   mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
   155 
   156   pushd classes >/dev/null
   157 
   158   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   159   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   160   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   161 
   162   jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
   163     fail "Failed to produce $TARGET"
   164 
   165   cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
   166 
   167   popd >/dev/null
   168 
   169   rm -rf classes
   170 fi