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