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