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