src/Pure/build-jars
author wenzelm
Tue Oct 11 11:30:02 2016 +0200 (2016-10-11)
changeset 64143 578e71c2c976
parent 64123 a967b5a07f92
child 64148 bbf43b7c4d0d
permissions -rwxr-xr-x
added isabelle remote_dmg tool;
     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/remote_dmg.scala
   128   Tools/simplifier_trace.scala
   129   Tools/task_statistics.scala
   130   Tools/update_cartouches.scala
   131   Tools/update_header.scala
   132   Tools/update_then.scala
   133   Tools/update_theorems.scala
   134   library.scala
   135   term.scala
   136   term_xml.scala
   137   "../Tools/Graphview/graph_file.scala"
   138   "../Tools/Graphview/graph_panel.scala"
   139   "../Tools/Graphview/graphview.scala"
   140   "../Tools/Graphview/layout.scala"
   141   "../Tools/Graphview/main_panel.scala"
   142   "../Tools/Graphview/metrics.scala"
   143   "../Tools/Graphview/model.scala"
   144   "../Tools/Graphview/mutator.scala"
   145   "../Tools/Graphview/mutator_dialog.scala"
   146   "../Tools/Graphview/mutator_event.scala"
   147   "../Tools/Graphview/popups.scala"
   148   "../Tools/Graphview/shapes.scala"
   149   "../Tools/Graphview/tree_panel.scala"
   150 )
   151 
   152 
   153 ## diagnostics
   154 
   155 PRG="$(basename "$0")"
   156 
   157 function usage()
   158 {
   159   echo
   160   echo "Usage: isabelle $PRG [OPTIONS]"
   161   echo
   162   echo "  Options are:"
   163   echo "    -f           fresh build"
   164   echo "    -t           test separate compilation of PIDE"
   165   echo
   166   exit 1
   167 }
   168 
   169 function fail()
   170 {
   171   echo "$1" >&2
   172   exit 2
   173 }
   174 
   175 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   176 
   177 
   178 ## process command line
   179 
   180 # options
   181 
   182 FRESH=""
   183 TEST_PIDE=""
   184 
   185 while getopts "ft" OPT
   186 do
   187   case "$OPT" in
   188     f)
   189       FRESH=true
   190       ;;
   191     t)
   192       TEST_PIDE=true
   193       ;;
   194     \?)
   195       usage
   196       ;;
   197   esac
   198 done
   199 
   200 shift $(($OPTIND - 1))
   201 
   202 
   203 # args
   204 
   205 [ "$#" -ne 0 ] && usage
   206 
   207 
   208 ## build
   209 
   210 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   211 TARGET="$TARGET_DIR/Pure.jar"
   212 
   213 declare -a PIDE_SOURCES=()
   214 declare -a PURE_SOURCES=()
   215 
   216 for DEP in "${SOURCES[@]}"
   217 do
   218   if grep "Module:.*PIDE" "$DEP" >/dev/null
   219   then
   220     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   221   else
   222     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   223   fi
   224 done
   225 
   226 declare -a UPDATED=()
   227 
   228 if [ -n "$FRESH" ]; then
   229   OUTDATED=true
   230 else
   231   OUTDATED=false
   232   if [ ! -e "$TARGET" ]; then
   233     OUTDATED=true
   234   else
   235     for DEP in "${SOURCES[@]}"
   236     do
   237       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   238       [ "$DEP" -nt "$TARGET" ] && {
   239         OUTDATED=true
   240         UPDATED["${#UPDATED[@]}"]="$DEP"
   241       }
   242     done
   243   fi
   244 fi
   245 
   246 if [ "$OUTDATED" = true ]
   247 then
   248   echo "### Building Isabelle/Scala ..."
   249 
   250   [ "${#UPDATED[@]}" -gt 0 ] && {
   251     echo "Changed files:"
   252     for FILE in "${UPDATED[@]}"
   253     do
   254       echo "  $FILE"
   255     done
   256   }
   257 
   258   rm -rf classes && mkdir classes
   259 
   260   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   261 
   262   (
   263     classpath "$JAVA_HOME/lib/jfxrt.jar"
   264     classpath classes
   265     export CLASSPATH="$(platform_path "$ISABELLE_CLASSPATH")"
   266 
   267     if [ "$TEST_PIDE" = true ]; then
   268       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   269         fail "Failed to compile PIDE sources"
   270       isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
   271         fail "Failed to compile Pure sources"
   272     else
   273       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   274         fail "Failed to compile sources"
   275     fi
   276   ) || exit "$?"
   277 
   278   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   279 
   280   pushd classes >/dev/null
   281 
   282   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   283   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   284   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   285 
   286   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   287   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   288 
   289   isabelle_jdk jar cfe "$(platform_path "$TARGET")" isabelle.Main META-INF isabelle || \
   290     fail "Failed to produce $TARGET"
   291 
   292   popd >/dev/null
   293 
   294   rm -rf classes
   295 fi