src/Pure/build-jars
author wenzelm
Mon Feb 23 14:50:30 2015 +0100 (2015-02-23)
changeset 59564 fdc03c8daacc
parent 59459 985fc55e9f27
child 59713 6da3efec20ca
permissions -rwxr-xr-x
Goal.prove_multi is superseded by the fully general Goal.prove_common;
     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/consumer_thread.scala
    13   Concurrent/counter.scala
    14   Concurrent/event_timer.scala
    15   Concurrent/future.scala
    16   Concurrent/mailbox.scala
    17   Concurrent/par_list.scala
    18   Concurrent/simple_thread.scala
    19   Concurrent/synchronized.scala
    20   GUI/color_value.scala
    21   GUI/gui.scala
    22   GUI/gui_thread.scala
    23   GUI/html5_panel.scala
    24   GUI/jfx_gui.scala
    25   GUI/popup.scala
    26   GUI/system_dialog.scala
    27   GUI/wrap_panel.scala
    28   General/antiquote.scala
    29   General/bytes.scala
    30   General/completion.scala
    31   General/exn.scala
    32   General/file.scala
    33   General/graph.scala
    34   General/graph_display.scala
    35   General/graphics_file.scala
    36   General/linear_set.scala
    37   General/long_name.scala
    38   General/multi_map.scala
    39   General/output.scala
    40   General/path.scala
    41   General/position.scala
    42   General/pretty.scala
    43   General/properties.scala
    44   General/scan.scala
    45   General/sha1.scala
    46   General/symbol.scala
    47   General/time.scala
    48   General/timing.scala
    49   General/untyped.scala
    50   General/url.scala
    51   General/word.scala
    52   General/xz_file.scala
    53   Isar/keyword.scala
    54   Isar/outer_syntax.scala
    55   Isar/parse.scala
    56   Isar/token.scala
    57   ML/ml_lex.scala
    58   PIDE/batch_session.scala
    59   PIDE/command.scala
    60   PIDE/command_span.scala
    61   PIDE/document.scala
    62   PIDE/document_id.scala
    63   PIDE/editor.scala
    64   PIDE/markup.scala
    65   PIDE/markup_tree.scala
    66   PIDE/protocol.scala
    67   PIDE/prover.scala
    68   PIDE/query_operation.scala
    69   PIDE/resources.scala
    70   PIDE/session.scala
    71   PIDE/text.scala
    72   PIDE/xml.scala
    73   PIDE/yxml.scala
    74   ROOT.scala
    75   System/command_line.scala
    76   System/invoke_scala.scala
    77   System/isabelle_charset.scala
    78   System/isabelle_process.scala
    79   System/isabelle_system.scala
    80   System/options.scala
    81   System/platform.scala
    82   System/posix_interrupt.scala
    83   System/system_channel.scala
    84   System/utf8.scala
    85   Thy/html.scala
    86   Thy/present.scala
    87   Thy/thy_header.scala
    88   Thy/thy_info.scala
    89   Thy/thy_syntax.scala
    90   Tools/bibtex.scala
    91   Tools/build.scala
    92   Tools/build_console.scala
    93   Tools/build_doc.scala
    94   Tools/check_source.scala
    95   Tools/doc.scala
    96   Tools/main.scala
    97   Tools/ml_statistics.scala
    98   Tools/print_operation.scala
    99   Tools/simplifier_trace.scala
   100   Tools/task_statistics.scala
   101   Tools/update_cartouches.scala
   102   Tools/update_header.scala
   103   Tools/update_semicolons.scala
   104   library.scala
   105   term.scala
   106   term_xml.scala
   107   "../Tools/Graphview/graph_file.scala"
   108   "../Tools/Graphview/graph_panel.scala"
   109   "../Tools/Graphview/graphview.scala"
   110   "../Tools/Graphview/layout.scala"
   111   "../Tools/Graphview/main_panel.scala"
   112   "../Tools/Graphview/metrics.scala"
   113   "../Tools/Graphview/model.scala"
   114   "../Tools/Graphview/mutator.scala"
   115   "../Tools/Graphview/mutator_dialog.scala"
   116   "../Tools/Graphview/mutator_event.scala"
   117   "../Tools/Graphview/popups.scala"
   118   "../Tools/Graphview/shapes.scala"
   119   "../Tools/Graphview/tree_panel.scala"
   120 )
   121 
   122 
   123 ## diagnostics
   124 
   125 PRG="$(basename "$0")"
   126 
   127 function usage()
   128 {
   129   echo
   130   echo "Usage: isabelle $PRG [OPTIONS]"
   131   echo
   132   echo "  Options are:"
   133   echo "    -f           fresh build"
   134   echo "    -t           test separate compilation of PIDE"
   135   echo
   136   exit 1
   137 }
   138 
   139 function fail()
   140 {
   141   echo "$1" >&2
   142   exit 2
   143 }
   144 
   145 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   146 
   147 
   148 ## process command line
   149 
   150 # options
   151 
   152 FRESH=""
   153 TEST_PIDE=""
   154 
   155 while getopts "ft" OPT
   156 do
   157   case "$OPT" in
   158     f)
   159       FRESH=true
   160       ;;
   161     t)
   162       TEST_PIDE=true
   163       ;;
   164     \?)
   165       usage
   166       ;;
   167   esac
   168 done
   169 
   170 shift $(($OPTIND - 1))
   171 
   172 
   173 # args
   174 
   175 [ "$#" -ne 0 ] && usage
   176 
   177 
   178 ## build
   179 
   180 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   181 TARGET="$TARGET_DIR/Pure.jar"
   182 
   183 declare -a PIDE_SOURCES=()
   184 declare -a PURE_SOURCES=()
   185 
   186 for DEP in "${SOURCES[@]}"
   187 do
   188   if grep "Module:.*PIDE" "$DEP" >/dev/null
   189   then
   190     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   191   else
   192     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   193   fi
   194 done
   195 
   196 declare -a UPDATED=()
   197 
   198 if [ -n "$FRESH" ]; then
   199   OUTDATED=true
   200 else
   201   OUTDATED=false
   202   if [ ! -e "$TARGET" ]; then
   203     OUTDATED=true
   204   else
   205     for DEP in "${SOURCES[@]}"
   206     do
   207       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   208       [ "$DEP" -nt "$TARGET" ] && {
   209         OUTDATED=true
   210         UPDATED["${#UPDATED[@]}"]="$DEP"
   211       }
   212     done
   213   fi
   214 fi
   215 
   216 if [ "$OUTDATED" = true ]
   217 then
   218   echo "### Building Isabelle/Scala ..."
   219 
   220   [ "${#UPDATED[@]}" -gt 0 ] && {
   221     echo "Changed files:"
   222     for FILE in "${UPDATED[@]}"
   223     do
   224       echo "  $FILE"
   225     done
   226   }
   227 
   228   rm -rf classes && mkdir classes
   229 
   230   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   231 
   232   (
   233     classpath "$JAVA_HOME/lib/jfxrt.jar"
   234     classpath classes
   235     export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
   236 
   237     if [ "$TEST_PIDE" = true ]; then
   238       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   239         fail "Failed to compile PIDE sources"
   240       isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
   241         fail "Failed to compile Pure sources"
   242     else
   243       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   244         fail "Failed to compile sources"
   245     fi
   246   ) || exit "$?"
   247 
   248   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   249 
   250   pushd classes >/dev/null
   251 
   252   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   253   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   254   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   255 
   256   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   257   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   258 
   259   isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
   260     fail "Failed to produce $TARGET"
   261 
   262   popd >/dev/null
   263 
   264   rm -rf classes
   265 fi