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