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