src/Pure/build-jars
author wenzelm
Tue Jul 12 15:17:37 2011 +0200 (2011-07-12)
changeset 43776 6dd13e111d30
parent 43767 e0219ef7f84c
child 43779 47bec02c6762
permissions -rwxr-xr-x
discontinued obsolete Isabelle_Syntax and Parse_Value -- superseded by Outer_Syntax.quote_string and XML.Encode, Term_XML.Encode etc.;
     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 )
    61 
    62 
    63 ## diagnostics
    64 
    65 PRG="$(basename "$0")"
    66 
    67 function usage()
    68 {
    69   echo
    70   echo "Usage: isabelle $PRG [OPTIONS]"
    71   echo
    72   echo "  Options are:"
    73   echo "    -f           fresh build"
    74   echo
    75   exit 1
    76 }
    77 
    78 function fail()
    79 {
    80   echo "$1" >&2
    81   exit 2
    82 }
    83 
    84 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    85 [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
    86 
    87 
    88 ## process command line
    89 
    90 # options
    91 
    92 FRESH=""
    93 
    94 while getopts "f" OPT
    95 do
    96   case "$OPT" in
    97     f)
    98       FRESH=true
    99       ;;
   100     \?)
   101       usage
   102       ;;
   103   esac
   104 done
   105 
   106 shift $(($OPTIND - 1))
   107 
   108 
   109 # args
   110 
   111 [ "$#" -ne 0 ] && usage
   112 
   113 
   114 
   115 # build
   116 
   117 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   118 TARGET="$TARGET_DIR/ext/Pure.jar"
   119 
   120 declare -a UPDATED=()
   121 
   122 if [ -n "$FRESH" ]; then
   123   OUTDATED=true
   124 else
   125   OUTDATED=false
   126   if [ ! -e "$TARGET" ]; then
   127     OUTDATED=true
   128   else
   129     for DEP in "${SOURCES[@]}"
   130     do
   131       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   132       [ "$DEP" -nt "$TARGET" ] && {
   133         OUTDATED=true
   134         UPDATED["${#UPDATED[@]}"]="$DEP"
   135       }
   136     done
   137   fi
   138 fi
   139 
   140 if [ "$OUTDATED" = true ]
   141 then
   142   echo "### Building Isabelle/Scala layer ..."
   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