src/Pure/build-jars
author wenzelm
Sun Apr 30 23:11:51 2017 +0200 (2017-04-30)
changeset 65650 48ef286b847b
parent 65557 29c69a599743
child 65734 03257db12a04
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   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_profile.scala
    23   Admin/isabelle_cronjob.scala
    24   Admin/jenkins.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_console.scala
    86   ML/ml_lex.scala
    87   ML/ml_process.scala
    88   ML/ml_statistics.scala
    89   ML/ml_syntax.scala
    90   PIDE/command.scala
    91   PIDE/command_span.scala
    92   PIDE/document.scala
    93   PIDE/document_id.scala
    94   PIDE/editor.scala
    95   PIDE/line.scala
    96   PIDE/markup.scala
    97   PIDE/markup_tree.scala
    98   PIDE/protocol.scala
    99   PIDE/protocol_handlers.scala
   100   PIDE/protocol_message.scala
   101   PIDE/prover.scala
   102   PIDE/query_operation.scala
   103   PIDE/rendering.scala
   104   PIDE/resources.scala
   105   PIDE/session.scala
   106   PIDE/text.scala
   107   PIDE/xml.scala
   108   PIDE/yxml.scala
   109   ROOT.scala
   110   System/bash.scala
   111   System/command_line.scala
   112   System/cygwin.scala
   113   System/distribution.scala
   114   System/getopts.scala
   115   System/invoke_scala.scala
   116   System/isabelle_charset.scala
   117   System/isabelle_process.scala
   118   System/isabelle_system.scala
   119   System/isabelle_tool.scala
   120   System/numa.scala
   121   System/options.scala
   122   System/platform.scala
   123   System/posix_interrupt.scala
   124   System/process_result.scala
   125   System/progress.scala
   126   System/system_channel.scala
   127   Thy/html.scala
   128   Thy/present.scala
   129   Thy/sessions.scala
   130   Thy/thy_header.scala
   131   Thy/thy_info.scala
   132   Thy/thy_syntax.scala
   133   Tools/bibtex.scala
   134   Tools/build.scala
   135   Tools/check_keywords.scala
   136   Tools/debugger.scala
   137   Tools/doc.scala
   138   Tools/imports.scala
   139   Tools/main.scala
   140   Tools/print_operation.scala
   141   Tools/profiling_report.scala
   142   Tools/simplifier_trace.scala
   143   Tools/spell_checker.scala
   144   Tools/task_statistics.scala
   145   Tools/update_cartouches.scala
   146   Tools/update_header.scala
   147   Tools/update_then.scala
   148   Tools/update_theorems.scala
   149   library.scala
   150   term.scala
   151   term_xml.scala
   152   ../Tools/Graphview/graph_file.scala
   153   ../Tools/Graphview/graph_panel.scala
   154   ../Tools/Graphview/graphview.scala
   155   ../Tools/Graphview/layout.scala
   156   ../Tools/Graphview/main_panel.scala
   157   ../Tools/Graphview/metrics.scala
   158   ../Tools/Graphview/model.scala
   159   ../Tools/Graphview/mutator.scala
   160   ../Tools/Graphview/mutator_dialog.scala
   161   ../Tools/Graphview/mutator_event.scala
   162   ../Tools/Graphview/popups.scala
   163   ../Tools/Graphview/shapes.scala
   164   ../Tools/Graphview/tree_panel.scala
   165   ../Tools/VSCode/src/build_vscode.scala
   166   ../Tools/VSCode/src/channel.scala
   167   ../Tools/VSCode/src/document_model.scala
   168   ../Tools/VSCode/src/dynamic_output.scala
   169   ../Tools/VSCode/src/grammar.scala
   170   ../Tools/VSCode/src/protocol.scala
   171   ../Tools/VSCode/src/server.scala
   172   ../Tools/VSCode/src/vscode_rendering.scala
   173   ../Tools/VSCode/src/vscode_resources.scala
   174 )
   175 
   176 
   177 ## diagnostics
   178 
   179 PRG="$(basename "$0")"
   180 
   181 function usage()
   182 {
   183   echo
   184   echo "Usage: isabelle $PRG [OPTIONS]"
   185   echo
   186   echo "  Options are:"
   187   echo "    -f           fresh build"
   188   echo
   189   exit 1
   190 }
   191 
   192 function fail()
   193 {
   194   echo "$1" >&2
   195   exit 2
   196 }
   197 
   198 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   199 
   200 
   201 ## process command line
   202 
   203 # options
   204 
   205 FRESH=""
   206 
   207 while getopts "f" OPT
   208 do
   209   case "$OPT" in
   210     f)
   211       FRESH=true
   212       ;;
   213     \?)
   214       usage
   215       ;;
   216   esac
   217 done
   218 
   219 shift $(($OPTIND - 1))
   220 
   221 
   222 # args
   223 
   224 [ "$#" -ne 0 ] && usage
   225 
   226 
   227 ## build
   228 
   229 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   230 TARGET="$TARGET_DIR/Pure.jar"
   231 
   232 declare -a UPDATED=()
   233 
   234 if [ -n "$FRESH" ]; then
   235   OUTDATED=true
   236 else
   237   OUTDATED=false
   238   if [ ! -e "$TARGET" ]; then
   239     OUTDATED=true
   240   else
   241     for DEP in "${SOURCES[@]}"
   242     do
   243       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   244       [ "$DEP" -nt "$TARGET" ] && {
   245         OUTDATED=true
   246         UPDATED["${#UPDATED[@]}"]="$DEP"
   247       }
   248     done
   249   fi
   250 fi
   251 
   252 if [ "$OUTDATED" = true ]
   253 then
   254   echo "### Building Isabelle/Scala ..."
   255 
   256   [ "${#UPDATED[@]}" -gt 0 ] && {
   257     echo "Changed files:"
   258     for FILE in "${UPDATED[@]}"
   259     do
   260       echo "  $FILE"
   261     done
   262   }
   263 
   264   rm -f "$TARGET"
   265   rm -rf classes && mkdir classes
   266 
   267   SCALAC_OPTIONS="$ISABELLE_SCALAC_OPTIONS -d classes"
   268 
   269   (
   270     classpath "$JAVA_HOME/lib/jfxrt.jar"
   271     classpath classes
   272     export CLASSPATH="$(platform_path "$ISABELLE_CLASSPATH")"
   273 
   274     isabelle_scala scalac $SCALAC_OPTIONS "${SOURCES[@]}" || \
   275       fail "Failed to compile sources"
   276   ) || exit "$?"
   277 
   278   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   279 
   280   pushd classes >/dev/null
   281 
   282   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   283   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   284   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   285 
   286   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   287   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   288 
   289   isabelle_jdk jar cfe "$(platform_path "$TARGET")" isabelle.Main META-INF isabelle || \
   290     fail "Failed to produce $TARGET"
   291 
   292   popd >/dev/null
   293 
   294   rm -rf classes
   295 fi