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