src/Pure/build-jars
author wenzelm
Mon Jul 04 16:27:11 2011 +0200 (2011-07-04)
changeset 43651 511df47bcadc
parent 43600 4ac04bf9ff89
child 43660 bfc0bb115fa1
permissions -rwxr-xr-x
some support for theory files within Isabelle/Scala session;
     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_info.scala
    54   Thy/thy_load.scala
    55   Thy/thy_syntax.scala
    56   library.scala
    57   package.scala
    58 )
    59 
    60 
    61 ## diagnostics
    62 
    63 PRG="$(basename "$0")"
    64 
    65 function usage()
    66 {
    67   echo
    68   echo "Usage: isabelle $PRG [OPTIONS]"
    69   echo
    70   echo "  Options are:"
    71   echo "    -f           fresh build"
    72   echo
    73   exit 1
    74 }
    75 
    76 function fail()
    77 {
    78   echo "$1" >&2
    79   exit 2
    80 }
    81 
    82 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    83 [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
    84 
    85 
    86 ## process command line
    87 
    88 # options
    89 
    90 FRESH=""
    91 
    92 while getopts "f" OPT
    93 do
    94   case "$OPT" in
    95     f)
    96       FRESH=true
    97       ;;
    98     \?)
    99       usage
   100       ;;
   101   esac
   102 done
   103 
   104 shift $(($OPTIND - 1))
   105 
   106 
   107 # args
   108 
   109 [ "$#" -ne 0 ] && usage
   110 
   111 
   112 
   113 # build
   114 
   115 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   116 TARGET="$TARGET_DIR/ext/Pure.jar"
   117 
   118 declare -a UPDATED=()
   119 
   120 if [ -n "$FRESH" ]; then
   121   OUTDATED=true
   122 else
   123   OUTDATED=false
   124   if [ ! -e "$TARGET" ]; then
   125     OUTDATED=true
   126   else
   127     for DEP in "${SOURCES[@]}"
   128     do
   129       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   130       [ "$DEP" -nt "$TARGET" ] && {
   131         OUTDATED=true
   132         UPDATED["${#UPDATED[@]}"]="$DEP"
   133       }
   134     done
   135   fi
   136 fi
   137 
   138 if [ "$OUTDATED" = true ]
   139 then
   140   echo "###"
   141   echo "### Building Isabelle/Scala layer ..."
   142   echo "###"
   143 
   144   [ "${#UPDATED[@]}" -gt 0 ] && {
   145     echo "Changed files:"
   146     for FILE in "${UPDATED[@]}"
   147     do
   148       echo "  $FILE"
   149     done
   150   }
   151 
   152   rm -rf classes && mkdir classes
   153   "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
   154     fail "Failed to compile sources"
   155   mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
   156 
   157   pushd classes >/dev/null
   158 
   159   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   160   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   161   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   162 
   163   jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
   164     fail "Failed to produce $TARGET"
   165 
   166   cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
   167 
   168   popd >/dev/null
   169 
   170   rm -rf classes
   171 fi