src/Pure/build-jars
author wenzelm
Sun Jan 18 17:34:14 2015 +0100 (2015-01-18)
changeset 59392 02bacfc31446
parent 59362 41f1645a4f63
child 59441 ab2c3597f1d3
permissions -rwxr-xr-x
support for tree view on graph nodes;
misc tuning;
     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_panel.scala"
   108   "../Tools/Graphview/layout.scala"
   109   "../Tools/Graphview/main_panel.scala"
   110   "../Tools/Graphview/metrics.scala"
   111   "../Tools/Graphview/model.scala"
   112   "../Tools/Graphview/mutator.scala"
   113   "../Tools/Graphview/mutator_dialog.scala"
   114   "../Tools/Graphview/mutator_event.scala"
   115   "../Tools/Graphview/popups.scala"
   116   "../Tools/Graphview/shapes.scala"
   117   "../Tools/Graphview/tree_panel.scala"
   118   "../Tools/Graphview/visualizer.scala"
   119 )
   120 
   121 
   122 ## diagnostics
   123 
   124 PRG="$(basename "$0")"
   125 
   126 function usage()
   127 {
   128   echo
   129   echo "Usage: isabelle $PRG [OPTIONS]"
   130   echo
   131   echo "  Options are:"
   132   echo "    -f           fresh build"
   133   echo "    -t           test separate compilation of PIDE"
   134   echo
   135   exit 1
   136 }
   137 
   138 function fail()
   139 {
   140   echo "$1" >&2
   141   exit 2
   142 }
   143 
   144 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   145 
   146 
   147 ## process command line
   148 
   149 # options
   150 
   151 FRESH=""
   152 TEST_PIDE=""
   153 
   154 while getopts "ft" OPT
   155 do
   156   case "$OPT" in
   157     f)
   158       FRESH=true
   159       ;;
   160     t)
   161       TEST_PIDE=true
   162       ;;
   163     \?)
   164       usage
   165       ;;
   166   esac
   167 done
   168 
   169 shift $(($OPTIND - 1))
   170 
   171 
   172 # args
   173 
   174 [ "$#" -ne 0 ] && usage
   175 
   176 
   177 ## build
   178 
   179 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   180 TARGET="$TARGET_DIR/Pure.jar"
   181 
   182 declare -a PIDE_SOURCES=()
   183 declare -a PURE_SOURCES=()
   184 
   185 for DEP in "${SOURCES[@]}"
   186 do
   187   if grep "Module:.*PIDE" "$DEP" >/dev/null
   188   then
   189     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   190   else
   191     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   192   fi
   193 done
   194 
   195 declare -a UPDATED=()
   196 
   197 if [ -n "$FRESH" ]; then
   198   OUTDATED=true
   199 else
   200   OUTDATED=false
   201   if [ ! -e "$TARGET" ]; then
   202     OUTDATED=true
   203   else
   204     for DEP in "${SOURCES[@]}"
   205     do
   206       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   207       [ "$DEP" -nt "$TARGET" ] && {
   208         OUTDATED=true
   209         UPDATED["${#UPDATED[@]}"]="$DEP"
   210       }
   211     done
   212   fi
   213 fi
   214 
   215 if [ "$OUTDATED" = true ]
   216 then
   217   echo "### Building Isabelle/Scala ..."
   218 
   219   [ "${#UPDATED[@]}" -gt 0 ] && {
   220     echo "Changed files:"
   221     for FILE in "${UPDATED[@]}"
   222     do
   223       echo "  $FILE"
   224     done
   225   }
   226 
   227   rm -rf classes && mkdir classes
   228 
   229   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   230 
   231   (
   232     classpath "$JAVA_HOME/lib/jfxrt.jar"
   233     classpath classes
   234     export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
   235 
   236     if [ "$TEST_PIDE" = true ]; then
   237       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   238         fail "Failed to compile PIDE sources"
   239       isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
   240         fail "Failed to compile Pure sources"
   241     else
   242       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   243         fail "Failed to compile sources"
   244     fi
   245   ) || exit "$?"
   246 
   247   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   248 
   249   pushd classes >/dev/null
   250 
   251   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   252   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   253   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   254 
   255   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   256   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   257 
   258   isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
   259     fail "Failed to produce $TARGET"
   260 
   261   popd >/dev/null
   262 
   263   rm -rf classes
   264 fi