src/Pure/build-jars
author wenzelm
Sun, 01 Dec 2013 13:03:15 +0100
changeset 55308 b636dab842f3
parent 55307 a6697947e277
child 55318 03826ceb24da
child 56013 d64a4ef26edb
permissions -rwxr-xr-x
more isabelle logos (from isabelle.ico);
     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/file.scala
    18   General/graph.scala
    19   General/graphics_file.scala
    20   General/linear_set.scala
    21   General/multi_map.scala
    22   General/path.scala
    23   General/position.scala
    24   General/pretty.scala
    25   General/properties.scala
    26   General/scan.scala
    27   General/sha1.scala
    28   General/symbol.scala
    29   General/time.scala
    30   General/timing.scala
    31   General/xz_file.scala
    32   GUI/color_value.scala
    33   GUI/gui.scala
    34   GUI/html5_panel.scala
    35   GUI/jfx_thread.scala
    36   GUI/popup.scala
    37   GUI/swing_thread.scala
    38   GUI/system_dialog.scala
    39   GUI/wrap_panel.scala
    40   Isar/completion.scala
    41   Isar/keyword.scala
    42   Isar/outer_syntax.scala
    43   Isar/parse.scala
    44   Isar/token.scala
    45   PIDE/command.scala
    46   PIDE/document.scala
    47   PIDE/document_id.scala
    48   PIDE/editor.scala
    49   PIDE/markup.scala
    50   PIDE/markup_tree.scala
    51   PIDE/protocol.scala
    52   PIDE/query_operation.scala
    53   PIDE/text.scala
    54   PIDE/xml.scala
    55   PIDE/yxml.scala
    56   System/command_line.scala
    57   System/event_bus.scala
    58   System/interrupt.scala
    59   System/invoke_scala.scala
    60   System/isabelle_charset.scala
    61   System/isabelle_font.scala
    62   System/isabelle_process.scala
    63   System/isabelle_system.scala
    64   System/options.scala
    65   System/platform.scala
    66   System/session.scala
    67   System/system_channel.scala
    68   System/utf8.scala
    69   Thy/html.scala
    70   Thy/present.scala
    71   Thy/thy_header.scala
    72   Thy/thy_info.scala
    73   Thy/thy_load.scala
    74   Thy/thy_syntax.scala
    75   Tools/build.scala
    76   Tools/doc.scala
    77   Tools/keywords.scala
    78   Tools/main.scala
    79   Tools/ml_statistics.scala
    80   Tools/sledgehammer_params.scala
    81   Tools/task_statistics.scala
    82   library.scala
    83   package.scala
    84   term.scala
    85   term_xml.scala
    86 )
    87 
    88 
    89 ## diagnostics
    90 
    91 PRG="$(basename "$0")"
    92 
    93 function usage()
    94 {
    95   echo
    96   echo "Usage: isabelle $PRG [OPTIONS]"
    97   echo
    98   echo "  Options are:"
    99   echo "    -f           fresh build"
   100   echo "    -t           test separate compilation of PIDE"
   101   echo
   102   exit 1
   103 }
   104 
   105 function fail()
   106 {
   107   echo "$1" >&2
   108   exit 2
   109 }
   110 
   111 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   112 
   113 
   114 ## process command line
   115 
   116 # options
   117 
   118 FRESH=""
   119 TEST_PIDE=""
   120 
   121 while getopts "ft" OPT
   122 do
   123   case "$OPT" in
   124     f)
   125       FRESH=true
   126       ;;
   127     t)
   128       TEST_PIDE=true
   129       ;;
   130     \?)
   131       usage
   132       ;;
   133   esac
   134 done
   135 
   136 shift $(($OPTIND - 1))
   137 
   138 
   139 # args
   140 
   141 [ "$#" -ne 0 ] && usage
   142 
   143 
   144 ## build
   145 
   146 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   147 TARGET="$TARGET_DIR/Pure.jar"
   148 
   149 declare -a PIDE_SOURCES=()
   150 declare -a PURE_SOURCES=()
   151 
   152 for DEP in "${SOURCES[@]}"
   153 do
   154   if grep "Module:.*PIDE" "$DEP" >/dev/null
   155   then
   156     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   157   else
   158     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   159   fi
   160 done
   161 
   162 declare -a UPDATED=()
   163 
   164 if [ -n "$FRESH" ]; then
   165   OUTDATED=true
   166 else
   167   OUTDATED=false
   168   if [ ! -e "$TARGET" ]; then
   169     OUTDATED=true
   170   else
   171     for DEP in "${SOURCES[@]}"
   172     do
   173       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   174       [ "$DEP" -nt "$TARGET" ] && {
   175         OUTDATED=true
   176         UPDATED["${#UPDATED[@]}"]="$DEP"
   177       }
   178     done
   179   fi
   180 fi
   181 
   182 if [ "$OUTDATED" = true ]
   183 then
   184   echo "### Building Isabelle/Scala ..."
   185 
   186   [ "${#UPDATED[@]}" -gt 0 ] && {
   187     echo "Changed files:"
   188     for FILE in "${UPDATED[@]}"
   189     do
   190       echo "  $FILE"
   191     done
   192   }
   193 
   194   rm -rf classes && mkdir classes
   195 
   196   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   197 
   198   (
   199     classpath "$ISABELLE_JDK_HOME/jre/lib/jfxrt.jar"
   200     classpath classes
   201     export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
   202 
   203     if [ "$TEST_PIDE" = true ]; then
   204       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   205         fail "Failed to compile PIDE sources"
   206       isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
   207         fail "Failed to compile Pure sources"
   208     else
   209       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   210         fail "Failed to compile sources"
   211     fi
   212   ) || exit "$?"
   213 
   214   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   215 
   216   pushd classes >/dev/null
   217 
   218   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   219   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   220   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   221 
   222   cp "$ISABELLE_HOME/lib/logo/isabelle-32.gif" isabelle/.
   223 
   224   isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
   225     fail "Failed to produce $TARGET"
   226 
   227   cp "$SCALA_HOME/lib/scala-compiler.jar" \
   228     "$SCALA_HOME/lib/scala-library.jar" \
   229     "$SCALA_HOME/lib/scala-swing.jar" \
   230     "$SCALA_HOME/lib/scala-actors.jar" \
   231     "$SCALA_HOME/lib/scala-reflect.jar" \
   232     "$TARGET_DIR"
   233 
   234   popd >/dev/null
   235 
   236   rm -rf classes
   237 fi