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