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