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