src/Pure/build-jars
author wenzelm
Tue Sep 29 23:43:35 2015 +0200 (2015-09-29)
changeset 61282 3e578ddef85d
parent 61276 8a4bd05c1735
child 61288 9399860edb46
permissions -rwxr-xr-x
clarified Isabelle_System.init;
clarified GUI.init_laf;
clarified modules;
tuned signature;
     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/cygwin.scala
    78   System/command_line.scala
    79   System/invoke_scala.scala
    80   System/isabelle_charset.scala
    81   System/isabelle_process.scala
    82   System/isabelle_system.scala
    83   System/options.scala
    84   System/platform.scala
    85   System/posix_interrupt.scala
    86   System/progress.scala
    87   System/system_channel.scala
    88   System/utf8.scala
    89   Thy/html.scala
    90   Thy/present.scala
    91   Thy/thy_header.scala
    92   Thy/thy_info.scala
    93   Thy/thy_syntax.scala
    94   Tools/bibtex.scala
    95   Tools/build.scala
    96   Tools/build_console.scala
    97   Tools/build_doc.scala
    98   Tools/check_keywords.scala
    99   Tools/check_source.scala
   100   Tools/debugger.scala
   101   Tools/doc.scala
   102   Tools/main.scala
   103   Tools/ml_statistics.scala
   104   Tools/print_operation.scala
   105   Tools/simplifier_trace.scala
   106   Tools/task_statistics.scala
   107   Tools/update_cartouches.scala
   108   Tools/update_header.scala
   109   Tools/update_semicolons.scala
   110   Tools/update_then.scala
   111   library.scala
   112   term.scala
   113   term_xml.scala
   114   "../Tools/Graphview/graph_file.scala"
   115   "../Tools/Graphview/graph_panel.scala"
   116   "../Tools/Graphview/graphview.scala"
   117   "../Tools/Graphview/layout.scala"
   118   "../Tools/Graphview/main_panel.scala"
   119   "../Tools/Graphview/metrics.scala"
   120   "../Tools/Graphview/model.scala"
   121   "../Tools/Graphview/mutator.scala"
   122   "../Tools/Graphview/mutator_dialog.scala"
   123   "../Tools/Graphview/mutator_event.scala"
   124   "../Tools/Graphview/popups.scala"
   125   "../Tools/Graphview/shapes.scala"
   126   "../Tools/Graphview/tree_panel.scala"
   127 )
   128 
   129 
   130 ## diagnostics
   131 
   132 PRG="$(basename "$0")"
   133 
   134 function usage()
   135 {
   136   echo
   137   echo "Usage: isabelle $PRG [OPTIONS]"
   138   echo
   139   echo "  Options are:"
   140   echo "    -f           fresh build"
   141   echo "    -t           test separate compilation of PIDE"
   142   echo
   143   exit 1
   144 }
   145 
   146 function fail()
   147 {
   148   echo "$1" >&2
   149   exit 2
   150 }
   151 
   152 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   153 
   154 
   155 ## process command line
   156 
   157 # options
   158 
   159 FRESH=""
   160 TEST_PIDE=""
   161 
   162 while getopts "ft" OPT
   163 do
   164   case "$OPT" in
   165     f)
   166       FRESH=true
   167       ;;
   168     t)
   169       TEST_PIDE=true
   170       ;;
   171     \?)
   172       usage
   173       ;;
   174   esac
   175 done
   176 
   177 shift $(($OPTIND - 1))
   178 
   179 
   180 # args
   181 
   182 [ "$#" -ne 0 ] && usage
   183 
   184 
   185 ## build
   186 
   187 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   188 TARGET="$TARGET_DIR/Pure.jar"
   189 
   190 declare -a PIDE_SOURCES=()
   191 declare -a PURE_SOURCES=()
   192 
   193 for DEP in "${SOURCES[@]}"
   194 do
   195   if grep "Module:.*PIDE" "$DEP" >/dev/null
   196   then
   197     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   198   else
   199     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   200   fi
   201 done
   202 
   203 declare -a UPDATED=()
   204 
   205 if [ -n "$FRESH" ]; then
   206   OUTDATED=true
   207 else
   208   OUTDATED=false
   209   if [ ! -e "$TARGET" ]; then
   210     OUTDATED=true
   211   else
   212     for DEP in "${SOURCES[@]}"
   213     do
   214       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   215       [ "$DEP" -nt "$TARGET" ] && {
   216         OUTDATED=true
   217         UPDATED["${#UPDATED[@]}"]="$DEP"
   218       }
   219     done
   220   fi
   221 fi
   222 
   223 if [ "$OUTDATED" = true ]
   224 then
   225   echo "### Building Isabelle/Scala ..."
   226 
   227   [ "${#UPDATED[@]}" -gt 0 ] && {
   228     echo "Changed files:"
   229     for FILE in "${UPDATED[@]}"
   230     do
   231       echo "  $FILE"
   232     done
   233   }
   234 
   235   rm -rf classes && mkdir classes
   236 
   237   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   238 
   239   (
   240     classpath "$JAVA_HOME/lib/jfxrt.jar"
   241     classpath classes
   242     export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
   243 
   244     if [ "$TEST_PIDE" = true ]; then
   245       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   246         fail "Failed to compile PIDE sources"
   247       isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
   248         fail "Failed to compile Pure sources"
   249     else
   250       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   251         fail "Failed to compile sources"
   252     fi
   253   ) || exit "$?"
   254 
   255   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   256 
   257   pushd classes >/dev/null
   258 
   259   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   260   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   261   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   262 
   263   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   264   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   265 
   266   isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
   267     fail "Failed to produce $TARGET"
   268 
   269   popd >/dev/null
   270 
   271   rm -rf classes
   272 fi