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