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