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