src/Pure/build-jars
author wenzelm
Thu Mar 10 09:50:53 2016 +0100 (2016-03-10)
changeset 62584 6cd36a0d2a28
parent 62559 83e815849a91
child 62586 a522a5692832
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   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/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   ML/ml_syntax.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/bash.scala
    77   System/command_line.scala
    78   System/cygwin.scala
    79   System/getopts.scala
    80   System/invoke_scala.scala
    81   System/isabelle_charset.scala
    82   System/isabelle_process.scala
    83   System/isabelle_system.scala
    84   System/ml_process.scala
    85   System/options.scala
    86   System/platform.scala
    87   System/posix_interrupt.scala
    88   System/process_result.scala
    89   System/progress.scala
    90   System/system_channel.scala
    91   System/utf8.scala
    92   Thy/html.scala
    93   Thy/present.scala
    94   Thy/thy_header.scala
    95   Thy/thy_info.scala
    96   Thy/thy_syntax.scala
    97   Tools/bibtex.scala
    98   Tools/build.scala
    99   Tools/build_doc.scala
   100   Tools/check_keywords.scala
   101   Tools/check_sources.scala
   102   Tools/debugger.scala
   103   Tools/doc.scala
   104   Tools/main.scala
   105   Tools/ml_console.scala
   106   Tools/ml_statistics.scala
   107   Tools/news.scala
   108   Tools/print_operation.scala
   109   Tools/simplifier_trace.scala
   110   Tools/task_statistics.scala
   111   Tools/update_cartouches.scala
   112   Tools/update_header.scala
   113   Tools/update_then.scala
   114   Tools/update_theorems.scala
   115   library.scala
   116   term.scala
   117   term_xml.scala
   118   "../Tools/Graphview/graph_file.scala"
   119   "../Tools/Graphview/graph_panel.scala"
   120   "../Tools/Graphview/graphview.scala"
   121   "../Tools/Graphview/layout.scala"
   122   "../Tools/Graphview/main_panel.scala"
   123   "../Tools/Graphview/metrics.scala"
   124   "../Tools/Graphview/model.scala"
   125   "../Tools/Graphview/mutator.scala"
   126   "../Tools/Graphview/mutator_dialog.scala"
   127   "../Tools/Graphview/mutator_event.scala"
   128   "../Tools/Graphview/popups.scala"
   129   "../Tools/Graphview/shapes.scala"
   130   "../Tools/Graphview/tree_panel.scala"
   131 )
   132 
   133 
   134 ## diagnostics
   135 
   136 PRG="$(basename "$0")"
   137 
   138 function usage()
   139 {
   140   echo
   141   echo "Usage: isabelle $PRG [OPTIONS]"
   142   echo
   143   echo "  Options are:"
   144   echo "    -f           fresh build"
   145   echo "    -t           test separate compilation of PIDE"
   146   echo
   147   exit 1
   148 }
   149 
   150 function fail()
   151 {
   152   echo "$1" >&2
   153   exit 2
   154 }
   155 
   156 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   157 
   158 
   159 ## process command line
   160 
   161 # options
   162 
   163 FRESH=""
   164 TEST_PIDE=""
   165 
   166 while getopts "ft" OPT
   167 do
   168   case "$OPT" in
   169     f)
   170       FRESH=true
   171       ;;
   172     t)
   173       TEST_PIDE=true
   174       ;;
   175     \?)
   176       usage
   177       ;;
   178   esac
   179 done
   180 
   181 shift $(($OPTIND - 1))
   182 
   183 
   184 # args
   185 
   186 [ "$#" -ne 0 ] && usage
   187 
   188 
   189 ## build
   190 
   191 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   192 TARGET="$TARGET_DIR/Pure.jar"
   193 
   194 declare -a PIDE_SOURCES=()
   195 declare -a PURE_SOURCES=()
   196 
   197 for DEP in "${SOURCES[@]}"
   198 do
   199   if grep "Module:.*PIDE" "$DEP" >/dev/null
   200   then
   201     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   202   else
   203     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   204   fi
   205 done
   206 
   207 declare -a UPDATED=()
   208 
   209 if [ -n "$FRESH" ]; then
   210   OUTDATED=true
   211 else
   212   OUTDATED=false
   213   if [ ! -e "$TARGET" ]; then
   214     OUTDATED=true
   215   else
   216     for DEP in "${SOURCES[@]}"
   217     do
   218       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   219       [ "$DEP" -nt "$TARGET" ] && {
   220         OUTDATED=true
   221         UPDATED["${#UPDATED[@]}"]="$DEP"
   222       }
   223     done
   224   fi
   225 fi
   226 
   227 if [ "$OUTDATED" = true ]
   228 then
   229   echo "### Building Isabelle/Scala ..."
   230 
   231   [ "${#UPDATED[@]}" -gt 0 ] && {
   232     echo "Changed files:"
   233     for FILE in "${UPDATED[@]}"
   234     do
   235       echo "  $FILE"
   236     done
   237   }
   238 
   239   rm -rf classes && mkdir classes
   240 
   241   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   242 
   243   (
   244     classpath "$JAVA_HOME/lib/jfxrt.jar"
   245     classpath classes
   246     export CLASSPATH="$(platform_path "$ISABELLE_CLASSPATH")"
   247 
   248     if [ "$TEST_PIDE" = true ]; then
   249       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   250         fail "Failed to compile PIDE sources"
   251       isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
   252         fail "Failed to compile Pure sources"
   253     else
   254       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   255         fail "Failed to compile sources"
   256     fi
   257   ) || exit "$?"
   258 
   259   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   260 
   261   pushd classes >/dev/null
   262 
   263   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   264   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   265   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   266 
   267   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   268   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   269 
   270   isabelle_jdk jar cfe "$(platform_path "$TARGET")" isabelle.Main META-INF isabelle || \
   271     fail "Failed to produce $TARGET"
   272 
   273   popd >/dev/null
   274 
   275   rm -rf classes
   276 fi