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