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