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