src/Pure/build-jars
author wenzelm
Tue Mar 07 13:55:49 2017 +0100 (2017-03-07)
changeset 65138 64dfee6bd243
parent 65077 2d6e716c9d6e
child 65139 0a2c0712e432
permissions -rwxr-xr-x
added admin tool "isabelle build_vscode";
     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/batch_session.scala
    88   PIDE/command.scala
    89   PIDE/command_span.scala
    90   PIDE/document.scala
    91   PIDE/document_id.scala
    92   PIDE/editor.scala
    93   PIDE/line.scala
    94   PIDE/markup.scala
    95   PIDE/markup_tree.scala
    96   PIDE/protocol.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/task_statistics.scala
   143   Tools/update_cartouches.scala
   144   Tools/update_header.scala
   145   Tools/update_then.scala
   146   Tools/update_theorems.scala
   147   library.scala
   148   term.scala
   149   term_xml.scala
   150   ../Tools/Graphview/graph_file.scala
   151   ../Tools/Graphview/graph_panel.scala
   152   ../Tools/Graphview/graphview.scala
   153   ../Tools/Graphview/layout.scala
   154   ../Tools/Graphview/main_panel.scala
   155   ../Tools/Graphview/metrics.scala
   156   ../Tools/Graphview/model.scala
   157   ../Tools/Graphview/mutator.scala
   158   ../Tools/Graphview/mutator_dialog.scala
   159   ../Tools/Graphview/mutator_event.scala
   160   ../Tools/Graphview/popups.scala
   161   ../Tools/Graphview/shapes.scala
   162   ../Tools/Graphview/tree_panel.scala
   163   ../Tools/VSCode/src/build_vscode.scala
   164   ../Tools/VSCode/src/channel.scala
   165   ../Tools/VSCode/src/document_model.scala
   166   ../Tools/VSCode/src/grammar.scala
   167   ../Tools/VSCode/src/protocol.scala
   168   ../Tools/VSCode/src/server.scala
   169   ../Tools/VSCode/src/vscode_rendering.scala
   170   ../Tools/VSCode/src/vscode_resources.scala
   171 )
   172 
   173 
   174 ## diagnostics
   175 
   176 PRG="$(basename "$0")"
   177 
   178 function usage()
   179 {
   180   echo
   181   echo "Usage: isabelle $PRG [OPTIONS]"
   182   echo
   183   echo "  Options are:"
   184   echo "    -f           fresh build"
   185   echo
   186   exit 1
   187 }
   188 
   189 function fail()
   190 {
   191   echo "$1" >&2
   192   exit 2
   193 }
   194 
   195 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   196 
   197 
   198 ## process command line
   199 
   200 # options
   201 
   202 FRESH=""
   203 
   204 while getopts "f" OPT
   205 do
   206   case "$OPT" in
   207     f)
   208       FRESH=true
   209       ;;
   210     \?)
   211       usage
   212       ;;
   213   esac
   214 done
   215 
   216 shift $(($OPTIND - 1))
   217 
   218 
   219 # args
   220 
   221 [ "$#" -ne 0 ] && usage
   222 
   223 
   224 ## build
   225 
   226 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   227 TARGET="$TARGET_DIR/Pure.jar"
   228 
   229 declare -a UPDATED=()
   230 
   231 if [ -n "$FRESH" ]; then
   232   OUTDATED=true
   233 else
   234   OUTDATED=false
   235   if [ ! -e "$TARGET" ]; then
   236     OUTDATED=true
   237   else
   238     for DEP in "${SOURCES[@]}"
   239     do
   240       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   241       [ "$DEP" -nt "$TARGET" ] && {
   242         OUTDATED=true
   243         UPDATED["${#UPDATED[@]}"]="$DEP"
   244       }
   245     done
   246   fi
   247 fi
   248 
   249 if [ "$OUTDATED" = true ]
   250 then
   251   echo "### Building Isabelle/Scala ..."
   252 
   253   [ "${#UPDATED[@]}" -gt 0 ] && {
   254     echo "Changed files:"
   255     for FILE in "${UPDATED[@]}"
   256     do
   257       echo "  $FILE"
   258     done
   259   }
   260 
   261   rm -f "$TARGET"
   262   rm -rf classes && mkdir classes
   263 
   264   SCALAC_OPTIONS="$ISABELLE_SCALAC_OPTIONS -d classes"
   265 
   266   (
   267     classpath "$JAVA_HOME/lib/jfxrt.jar"
   268     classpath classes
   269     export CLASSPATH="$(platform_path "$ISABELLE_CLASSPATH")"
   270 
   271     isabelle_scala scalac $SCALAC_OPTIONS "${SOURCES[@]}" || \
   272       fail "Failed to compile sources"
   273   ) || exit "$?"
   274 
   275   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   276 
   277   pushd classes >/dev/null
   278 
   279   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   280   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   281   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   282 
   283   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   284   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   285 
   286   isabelle_jdk jar cfe "$(platform_path "$TARGET")" isabelle.Main META-INF isabelle || \
   287     fail "Failed to produce $TARGET"
   288 
   289   popd >/dev/null
   290 
   291   rm -rf classes
   292 fi