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