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