src/Pure/build-jars
author wenzelm
Mon Mar 16 11:07:56 2015 +0100 (2015-03-16)
changeset 59713 6da3efec20ca
parent 59459 985fc55e9f27
child 59891 9ce697050455
permissions -rwxr-xr-x
clarified modules;
     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_source.scala
    96   Tools/doc.scala
    97   Tools/main.scala
    98   Tools/ml_statistics.scala
    99   Tools/print_operation.scala
   100   Tools/simplifier_trace.scala
   101   Tools/task_statistics.scala
   102   Tools/update_cartouches.scala
   103   Tools/update_header.scala
   104   Tools/update_semicolons.scala
   105   library.scala
   106   term.scala
   107   term_xml.scala
   108   "../Tools/Graphview/graph_file.scala"
   109   "../Tools/Graphview/graph_panel.scala"
   110   "../Tools/Graphview/graphview.scala"
   111   "../Tools/Graphview/layout.scala"
   112   "../Tools/Graphview/main_panel.scala"
   113   "../Tools/Graphview/metrics.scala"
   114   "../Tools/Graphview/model.scala"
   115   "../Tools/Graphview/mutator.scala"
   116   "../Tools/Graphview/mutator_dialog.scala"
   117   "../Tools/Graphview/mutator_event.scala"
   118   "../Tools/Graphview/popups.scala"
   119   "../Tools/Graphview/shapes.scala"
   120   "../Tools/Graphview/tree_panel.scala"
   121 )
   122 
   123 
   124 ## diagnostics
   125 
   126 PRG="$(basename "$0")"
   127 
   128 function usage()
   129 {
   130   echo
   131   echo "Usage: isabelle $PRG [OPTIONS]"
   132   echo
   133   echo "  Options are:"
   134   echo "    -f           fresh build"
   135   echo "    -t           test separate compilation of PIDE"
   136   echo
   137   exit 1
   138 }
   139 
   140 function fail()
   141 {
   142   echo "$1" >&2
   143   exit 2
   144 }
   145 
   146 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   147 
   148 
   149 ## process command line
   150 
   151 # options
   152 
   153 FRESH=""
   154 TEST_PIDE=""
   155 
   156 while getopts "ft" OPT
   157 do
   158   case "$OPT" in
   159     f)
   160       FRESH=true
   161       ;;
   162     t)
   163       TEST_PIDE=true
   164       ;;
   165     \?)
   166       usage
   167       ;;
   168   esac
   169 done
   170 
   171 shift $(($OPTIND - 1))
   172 
   173 
   174 # args
   175 
   176 [ "$#" -ne 0 ] && usage
   177 
   178 
   179 ## build
   180 
   181 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   182 TARGET="$TARGET_DIR/Pure.jar"
   183 
   184 declare -a PIDE_SOURCES=()
   185 declare -a PURE_SOURCES=()
   186 
   187 for DEP in "${SOURCES[@]}"
   188 do
   189   if grep "Module:.*PIDE" "$DEP" >/dev/null
   190   then
   191     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   192   else
   193     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   194   fi
   195 done
   196 
   197 declare -a UPDATED=()
   198 
   199 if [ -n "$FRESH" ]; then
   200   OUTDATED=true
   201 else
   202   OUTDATED=false
   203   if [ ! -e "$TARGET" ]; then
   204     OUTDATED=true
   205   else
   206     for DEP in "${SOURCES[@]}"
   207     do
   208       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   209       [ "$DEP" -nt "$TARGET" ] && {
   210         OUTDATED=true
   211         UPDATED["${#UPDATED[@]}"]="$DEP"
   212       }
   213     done
   214   fi
   215 fi
   216 
   217 if [ "$OUTDATED" = true ]
   218 then
   219   echo "### Building Isabelle/Scala ..."
   220 
   221   [ "${#UPDATED[@]}" -gt 0 ] && {
   222     echo "Changed files:"
   223     for FILE in "${UPDATED[@]}"
   224     do
   225       echo "  $FILE"
   226     done
   227   }
   228 
   229   rm -rf classes && mkdir classes
   230 
   231   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   232 
   233   (
   234     classpath "$JAVA_HOME/lib/jfxrt.jar"
   235     classpath classes
   236     export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
   237 
   238     if [ "$TEST_PIDE" = true ]; then
   239       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   240         fail "Failed to compile PIDE sources"
   241       isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
   242         fail "Failed to compile Pure sources"
   243     else
   244       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   245         fail "Failed to compile sources"
   246     fi
   247   ) || exit "$?"
   248 
   249   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   250 
   251   pushd classes >/dev/null
   252 
   253   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   254   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   255   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   256 
   257   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   258   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   259 
   260   isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
   261     fail "Failed to produce $TARGET"
   262 
   263   popd >/dev/null
   264 
   265   rm -rf classes
   266 fi