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