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