src/Pure/build-jars
author wenzelm
Thu, 01 Dec 2011 14:29:14 +0100
changeset 46587 87017fcbad83
parent 46549 eb65c9d17e2f
child 47482 669601fa1a62
permissions -rwxr-xr-x
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
     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/linear_set.scala
    18   General/path.scala
    19   General/position.scala
    20   General/pretty.scala
    21   General/properties.scala
    22   General/scan.scala
    23   General/sha1.scala
    24   General/symbol.scala
    25   General/time.scala
    26   General/timing.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/isabelle_markup.scala
    35   PIDE/markup.scala
    36   PIDE/markup_tree.scala
    37   PIDE/protocol.scala
    38   PIDE/text.scala
    39   PIDE/xml.scala
    40   PIDE/yxml.scala
    41   System/cygwin.scala
    42   System/download.scala
    43   System/event_bus.scala
    44   System/gui_setup.scala
    45   System/invoke_scala.scala
    46   System/isabelle_charset.scala
    47   System/isabelle_process.scala
    48   System/isabelle_system.scala
    49   System/platform.scala
    50   System/session.scala
    51   System/session_manager.scala
    52   System/standard_system.scala
    53   System/swing_thread.scala
    54   System/system_channel.scala
    55   Thy/completion.scala
    56   Thy/html.scala
    57   Thy/thy_header.scala
    58   Thy/thy_info.scala
    59   Thy/thy_load.scala
    60   Thy/thy_syntax.scala
    61   library.scala
    62   package.scala
    63   term.scala
    64   term_xml.scala
    65 )
    66 
    67 
    68 ## diagnostics
    69 
    70 PRG="$(basename "$0")"
    71 
    72 function usage()
    73 {
    74   echo
    75   echo "Usage: isabelle $PRG [OPTIONS]"
    76   echo
    77   echo "  Options are:"
    78   echo "    -f           fresh build"
    79   echo
    80   exit 1
    81 }
    82 
    83 function fail()
    84 {
    85   echo "$1" >&2
    86   exit 2
    87 }
    88 
    89 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    90 [ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
    91 
    92 
    93 ## process command line
    94 
    95 # options
    96 
    97 FRESH=""
    98 
    99 while getopts "f" OPT
   100 do
   101   case "$OPT" in
   102     f)
   103       FRESH=true
   104       ;;
   105     \?)
   106       usage
   107       ;;
   108   esac
   109 done
   110 
   111 shift $(($OPTIND - 1))
   112 
   113 
   114 # args
   115 
   116 [ "$#" -ne 0 ] && usage
   117 
   118 
   119 
   120 # build
   121 
   122 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   123 TARGET="$TARGET_DIR/ext/Pure.jar"
   124 
   125 declare -a PIDE_SOURCES=()
   126 declare -a PURE_SOURCES=()
   127 
   128 for DEP in "${SOURCES[@]}"
   129 do
   130   if grep "Module:.*PIDE" "$DEP" >/dev/null
   131   then
   132     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   133   else
   134     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   135   fi
   136 done
   137 
   138 declare -a UPDATED=()
   139 
   140 if [ -n "$FRESH" ]; then
   141   OUTDATED=true
   142 else
   143   OUTDATED=false
   144   if [ ! -e "$TARGET" ]; then
   145     OUTDATED=true
   146   else
   147     for DEP in "${SOURCES[@]}"
   148     do
   149       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   150       [ "$DEP" -nt "$TARGET" ] && {
   151         OUTDATED=true
   152         UPDATED["${#UPDATED[@]}"]="$DEP"
   153       }
   154     done
   155   fi
   156 fi
   157 
   158 if [ "$OUTDATED" = true ]
   159 then
   160   echo "### Building Isabelle/Scala layer ..."
   161 
   162   [ "${#UPDATED[@]}" -gt 0 ] && {
   163     echo "Changed files:"
   164     for FILE in "${UPDATED[@]}"
   165     do
   166       echo "  $FILE"
   167     done
   168   }
   169 
   170   rm -rf classes && mkdir classes
   171 
   172   SCALAC_OPTIONS="-unchecked -deprecation -d classes -target:jvm-1.5"
   173 
   174   "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   175     fail "Failed to compile PIDE sources"
   176 
   177   "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
   178     fail "Failed to compile Pure sources"
   179 
   180   mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
   181 
   182   pushd classes >/dev/null
   183 
   184   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   185   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   186   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   187 
   188   jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
   189     fail "Failed to produce $TARGET"
   190 
   191   cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
   192 
   193   popd >/dev/null
   194 
   195   rm -rf classes
   196 fi