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