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