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