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