src/Pure/build-jars
author wenzelm
Wed Dec 12 23:36:07 2012 +0100 (2012-12-12 ago)
changeset 50499 f496b2b7bafb
parent 50365 82f5aea343e7
child 50650 8922afc54b3d
permissions -rwxr-xr-x
rendering of selected dialog_result as active_result_color, depending on dynamic command status in output panel, but not static popups etc.;
     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/linear_set.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/time.scala
    28   General/timing.scala
    29   Isar/keyword.scala
    30   Isar/outer_syntax.scala
    31   Isar/parse.scala
    32   Isar/token.scala
    33   PIDE/command.scala
    34   PIDE/document.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/build.scala
    42   System/build_dialog.scala
    43   System/color_value.scala
    44   System/command_line.scala
    45   System/event_bus.scala
    46   System/gui_setup.scala
    47   System/html5_panel.scala
    48   System/invoke_scala.scala
    49   System/isabelle_charset.scala
    50   System/isabelle_process.scala
    51   System/isabelle_system.scala
    52   System/jfx_thread.scala
    53   System/main.scala
    54   System/options.scala
    55   System/platform.scala
    56   System/session.scala
    57   System/standard_system.scala
    58   System/swing_thread.scala
    59   System/system_channel.scala
    60   System/utf8.scala
    61   Thy/completion.scala
    62   Thy/html.scala
    63   Thy/thy_header.scala
    64   Thy/thy_info.scala
    65   Thy/thy_load.scala
    66   Thy/thy_syntax.scala
    67   library.scala
    68   package.scala
    69   term.scala
    70   term_xml.scala
    71 )
    72 
    73 
    74 ## diagnostics
    75 
    76 PRG="$(basename "$0")"
    77 
    78 function usage()
    79 {
    80   echo
    81   echo "Usage: isabelle $PRG [OPTIONS]"
    82   echo
    83   echo "  Options are:"
    84   echo "    -f           fresh build"
    85   echo "    -t           test separate compilation of PIDE"
    86   echo
    87   exit 1
    88 }
    89 
    90 function fail()
    91 {
    92   echo "$1" >&2
    93   exit 2
    94 }
    95 
    96 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    97 
    98 
    99 ## process command line
   100 
   101 # options
   102 
   103 FRESH=""
   104 TEST_PIDE=""
   105 
   106 while getopts "ft" OPT
   107 do
   108   case "$OPT" in
   109     f)
   110       FRESH=true
   111       ;;
   112     t)
   113       TEST_PIDE=true
   114       ;;
   115     \?)
   116       usage
   117       ;;
   118   esac
   119 done
   120 
   121 shift $(($OPTIND - 1))
   122 
   123 
   124 # args
   125 
   126 [ "$#" -ne 0 ] && usage
   127 
   128 
   129 ## build
   130 
   131 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   132 TARGET="$TARGET_DIR/ext/Pure.jar"
   133 
   134 declare -a PIDE_SOURCES=()
   135 declare -a PURE_SOURCES=()
   136 
   137 for DEP in "${SOURCES[@]}"
   138 do
   139   if grep "Module:.*PIDE" "$DEP" >/dev/null
   140   then
   141     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   142   else
   143     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   144   fi
   145 done
   146 
   147 declare -a UPDATED=()
   148 
   149 if [ -n "$FRESH" ]; then
   150   OUTDATED=true
   151 else
   152   OUTDATED=false
   153   if [ ! -e "$TARGET" ]; then
   154     OUTDATED=true
   155   else
   156     for DEP in "${SOURCES[@]}"
   157     do
   158       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   159       [ "$DEP" -nt "$TARGET" ] && {
   160         OUTDATED=true
   161         UPDATED["${#UPDATED[@]}"]="$DEP"
   162       }
   163     done
   164   fi
   165 fi
   166 
   167 if [ "$OUTDATED" = true ]
   168 then
   169   echo "### Building Isabelle/Scala ..."
   170 
   171   [ "${#UPDATED[@]}" -gt 0 ] && {
   172     echo "Changed files:"
   173     for FILE in "${UPDATED[@]}"
   174     do
   175       echo "  $FILE"
   176     done
   177   }
   178 
   179   rm -rf classes && mkdir classes
   180 
   181   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   182 
   183   JFXRT="$ISABELLE_JDK_HOME/jre/lib/jfxrt.jar"
   184 
   185   if [ "$TEST_PIDE" = true ]; then
   186     isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   187       fail "Failed to compile PIDE sources"
   188     isabelle_scala scalac $SCALAC_OPTIONS \
   189         -classpath "$(jvmpath "$JFXRT:classes")" "${PURE_SOURCES[@]}" || \
   190       fail "Failed to compile Pure sources"
   191   else
   192     isabelle_scala scalac $SCALAC_OPTIONS \
   193         -classpath "$(jvmpath "$JFXRT:classes")" "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   194       fail "Failed to compile sources"
   195   fi
   196 
   197   mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
   198 
   199   pushd classes >/dev/null
   200 
   201   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   202   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   203   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   204 
   205   isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
   206     fail "Failed to produce $TARGET"
   207 
   208   cp "$SCALA_HOME/lib/scala-compiler.jar" \
   209     "$SCALA_HOME/lib/scala-library.jar" \
   210     "$SCALA_HOME/lib/scala-swing.jar" "$TARGET_DIR/ext"
   211 
   212   [ -e "$SCALA_HOME/lib/scala-actors.jar" ] && \
   213     cp "$SCALA_HOME/lib/scala-actors.jar" "$TARGET_DIR/ext"
   214 
   215   [ -e "$SCALA_HOME/lib/scala-reflect.jar" ] && \
   216     cp "$SCALA_HOME/lib/scala-reflect.jar" "$TARGET_DIR/ext"
   217 
   218   popd >/dev/null
   219 
   220   rm -rf classes
   221 fi