src/Pure/build-jars
author wenzelm
Tue Jul 12 18:00:05 2011 +0200 (2011-07-12)
changeset 43779 47bec02c6762
parent 43776 6dd13e111d30
child 43780 2cb2310d68b6
permissions -rwxr-xr-x
more uniform Term and Term_XML modules;
     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/yxml.scala
    28   Isar/keyword.scala
    29   Isar/outer_syntax.scala
    30   Isar/parse.scala
    31   Isar/token.scala
    32   PIDE/blob.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/invoke_scala.scala
    43   System/isabelle_charset.scala
    44   System/isabelle_process.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   term.scala
    60   term_xml.scala
    61 )
    62 
    63 
    64 ## diagnostics
    65 
    66 PRG="$(basename "$0")"
    67 
    68 function usage()
    69 {
    70   echo
    71   echo "Usage: isabelle $PRG [OPTIONS]"
    72   echo
    73   echo "  Options are:"
    74   echo "    -f           fresh build"
    75   echo
    76   exit 1
    77 }
    78 
    79 function fail()
    80 {
    81   echo "$1" >&2
    82   exit 2
    83 }
    84 
    85 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    86 [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
    87 
    88 
    89 ## process command line
    90 
    91 # options
    92 
    93 FRESH=""
    94 
    95 while getopts "f" OPT
    96 do
    97   case "$OPT" in
    98     f)
    99       FRESH=true
   100       ;;
   101     \?)
   102       usage
   103       ;;
   104   esac
   105 done
   106 
   107 shift $(($OPTIND - 1))
   108 
   109 
   110 # args
   111 
   112 [ "$#" -ne 0 ] && usage
   113 
   114 
   115 
   116 # build
   117 
   118 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   119 TARGET="$TARGET_DIR/ext/Pure.jar"
   120 
   121 declare -a UPDATED=()
   122 
   123 if [ -n "$FRESH" ]; then
   124   OUTDATED=true
   125 else
   126   OUTDATED=false
   127   if [ ! -e "$TARGET" ]; then
   128     OUTDATED=true
   129   else
   130     for DEP in "${SOURCES[@]}"
   131     do
   132       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   133       [ "$DEP" -nt "$TARGET" ] && {
   134         OUTDATED=true
   135         UPDATED["${#UPDATED[@]}"]="$DEP"
   136       }
   137     done
   138   fi
   139 fi
   140 
   141 if [ "$OUTDATED" = true ]
   142 then
   143   echo "### Building Isabelle/Scala layer ..."
   144 
   145   [ "${#UPDATED[@]}" -gt 0 ] && {
   146     echo "Changed files:"
   147     for FILE in "${UPDATED[@]}"
   148     do
   149       echo "  $FILE"
   150     done
   151   }
   152 
   153   rm -rf classes && mkdir classes
   154   "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
   155     fail "Failed to compile sources"
   156   mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
   157 
   158   pushd classes >/dev/null
   159 
   160   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   161   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   162   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   163 
   164   jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
   165     fail "Failed to produce $TARGET"
   166 
   167   cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
   168 
   169   popd >/dev/null
   170 
   171   rm -rf classes
   172 fi