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