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