src/Pure/build-jars
author wenzelm
Sun Nov 02 16:47:45 2014 +0100 (2014-11-02)
changeset 58872 f0f623005324
parent 58861 5ff61774df11
child 58918 8d36bc5eaed3
permissions -rwxr-xr-x
added update_header tool;
     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/simple_thread.scala
    18   Concurrent/synchronized.scala
    19   GUI/color_value.scala
    20   GUI/gui.scala
    21   GUI/gui_thread.scala
    22   GUI/html5_panel.scala
    23   GUI/jfx_gui.scala
    24   GUI/popup.scala
    25   GUI/system_dialog.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/graphics_file.scala
    34   General/linear_set.scala
    35   General/long_name.scala
    36   General/multi_map.scala
    37   General/output.scala
    38   General/path.scala
    39   General/position.scala
    40   General/pretty.scala
    41   General/properties.scala
    42   General/scan.scala
    43   General/sha1.scala
    44   General/symbol.scala
    45   General/time.scala
    46   General/timing.scala
    47   General/untyped.scala
    48   General/url.scala
    49   General/word.scala
    50   General/xz_file.scala
    51   Isar/keyword.scala
    52   Isar/outer_syntax.scala
    53   Isar/parse.scala
    54   Isar/token.scala
    55   ML/ml_lex.scala
    56   PIDE/command.scala
    57   PIDE/command_span.scala
    58   PIDE/document.scala
    59   PIDE/document_id.scala
    60   PIDE/editor.scala
    61   PIDE/markup.scala
    62   PIDE/markup_tree.scala
    63   PIDE/protocol.scala
    64   PIDE/prover.scala
    65   PIDE/query_operation.scala
    66   PIDE/resources.scala
    67   PIDE/session.scala
    68   PIDE/text.scala
    69   PIDE/xml.scala
    70   PIDE/yxml.scala
    71   ROOT.scala
    72   System/command_line.scala
    73   System/invoke_scala.scala
    74   System/isabelle_charset.scala
    75   System/isabelle_process.scala
    76   System/isabelle_system.scala
    77   System/options.scala
    78   System/platform.scala
    79   System/posix_interrupt.scala
    80   System/system_channel.scala
    81   System/utf8.scala
    82   Thy/html.scala
    83   Thy/present.scala
    84   Thy/thy_header.scala
    85   Thy/thy_info.scala
    86   Thy/thy_syntax.scala
    87   Tools/bibtex.scala
    88   Tools/build.scala
    89   Tools/build_console.scala
    90   Tools/build_doc.scala
    91   Tools/check_source.scala
    92   Tools/doc.scala
    93   Tools/main.scala
    94   Tools/ml_statistics.scala
    95   Tools/print_operation.scala
    96   Tools/simplifier_trace.scala
    97   Tools/task_statistics.scala
    98   Tools/update_cartouches.scala
    99   Tools/update_header.scala
   100   Tools/update_semicolons.scala
   101   library.scala
   102   term.scala
   103   term_xml.scala
   104   "../Tools/Graphview/src/graph_panel.scala"
   105   "../Tools/Graphview/src/layout_pendulum.scala"
   106   "../Tools/Graphview/src/main_panel.scala"
   107   "../Tools/Graphview/src/model.scala"
   108   "../Tools/Graphview/src/mutator_dialog.scala"
   109   "../Tools/Graphview/src/mutator_event.scala"
   110   "../Tools/Graphview/src/mutator.scala"
   111   "../Tools/Graphview/src/popups.scala"
   112   "../Tools/Graphview/src/shapes.scala"
   113   "../Tools/Graphview/src/visualizer.scala"
   114 )
   115 
   116 
   117 ## diagnostics
   118 
   119 PRG="$(basename "$0")"
   120 
   121 function usage()
   122 {
   123   echo
   124   echo "Usage: isabelle $PRG [OPTIONS]"
   125   echo
   126   echo "  Options are:"
   127   echo "    -f           fresh build"
   128   echo "    -t           test separate compilation of PIDE"
   129   echo
   130   exit 1
   131 }
   132 
   133 function fail()
   134 {
   135   echo "$1" >&2
   136   exit 2
   137 }
   138 
   139 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   140 
   141 
   142 ## process command line
   143 
   144 # options
   145 
   146 FRESH=""
   147 TEST_PIDE=""
   148 
   149 while getopts "ft" OPT
   150 do
   151   case "$OPT" in
   152     f)
   153       FRESH=true
   154       ;;
   155     t)
   156       TEST_PIDE=true
   157       ;;
   158     \?)
   159       usage
   160       ;;
   161   esac
   162 done
   163 
   164 shift $(($OPTIND - 1))
   165 
   166 
   167 # args
   168 
   169 [ "$#" -ne 0 ] && usage
   170 
   171 
   172 ## build
   173 
   174 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   175 TARGET="$TARGET_DIR/Pure.jar"
   176 
   177 declare -a PIDE_SOURCES=()
   178 declare -a PURE_SOURCES=()
   179 
   180 for DEP in "${SOURCES[@]}"
   181 do
   182   if grep "Module:.*PIDE" "$DEP" >/dev/null
   183   then
   184     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   185   else
   186     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   187   fi
   188 done
   189 
   190 declare -a UPDATED=()
   191 
   192 if [ -n "$FRESH" ]; then
   193   OUTDATED=true
   194 else
   195   OUTDATED=false
   196   if [ ! -e "$TARGET" ]; then
   197     OUTDATED=true
   198   else
   199     for DEP in "${SOURCES[@]}"
   200     do
   201       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   202       [ "$DEP" -nt "$TARGET" ] && {
   203         OUTDATED=true
   204         UPDATED["${#UPDATED[@]}"]="$DEP"
   205       }
   206     done
   207   fi
   208 fi
   209 
   210 if [ "$OUTDATED" = true ]
   211 then
   212   echo "### Building Isabelle/Scala ..."
   213 
   214   [ "${#UPDATED[@]}" -gt 0 ] && {
   215     echo "Changed files:"
   216     for FILE in "${UPDATED[@]}"
   217     do
   218       echo "  $FILE"
   219     done
   220   }
   221 
   222   rm -rf classes && mkdir classes
   223 
   224   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   225 
   226   (
   227     classpath "$JAVA_HOME/lib/jfxrt.jar"
   228     classpath classes
   229     export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
   230 
   231     if [ "$TEST_PIDE" = true ]; then
   232       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   233         fail "Failed to compile PIDE sources"
   234       isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
   235         fail "Failed to compile Pure sources"
   236     else
   237       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   238         fail "Failed to compile sources"
   239     fi
   240   ) || exit "$?"
   241 
   242   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   243 
   244   pushd classes >/dev/null
   245 
   246   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   247   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   248   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   249 
   250   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   251   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   252 
   253   isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
   254     fail "Failed to produce $TARGET"
   255 
   256   popd >/dev/null
   257 
   258   rm -rf classes
   259 fi