src/Pure/build-jars
author wenzelm
Thu Aug 02 12:36:54 2012 +0200 (2012-08-02)
changeset 48646 91281e9472d8
parent 48411 5b3440850d36
child 49065 8ead9e8b15fb
permissions -rwxr-xr-x
more official command specifications, including source position;
     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/exn.scala
    17   General/file.scala
    18   General/graph.scala
    19   General/linear_set.scala
    20   General/path.scala
    21   General/position.scala
    22   General/pretty.scala
    23   General/properties.scala
    24   General/scan.scala
    25   General/sha1.scala
    26   General/symbol.scala
    27   General/time.scala
    28   General/timing.scala
    29   Isar/keyword.scala
    30   Isar/outer_syntax.scala
    31   Isar/parse.scala
    32   Isar/token.scala
    33   PIDE/blob.scala
    34   PIDE/command.scala
    35   PIDE/document.scala
    36   PIDE/isabelle_markup.scala
    37   PIDE/markup.scala
    38   PIDE/markup_tree.scala
    39   PIDE/protocol.scala
    40   PIDE/text.scala
    41   PIDE/xml.scala
    42   PIDE/yxml.scala
    43   System/build.scala
    44   System/command_line.scala
    45   System/event_bus.scala
    46   System/gui_setup.scala
    47   System/invoke_scala.scala
    48   System/isabelle_charset.scala
    49   System/isabelle_process.scala
    50   System/isabelle_system.scala
    51   System/main.scala
    52   System/options.scala
    53   System/platform.scala
    54   System/session.scala
    55   System/standard_system.scala
    56   System/swing_thread.scala
    57   System/system_channel.scala
    58   Thy/completion.scala
    59   Thy/html.scala
    60   Thy/thy_header.scala
    61   Thy/thy_info.scala
    62   Thy/thy_load.scala
    63   Thy/thy_syntax.scala
    64   library.scala
    65   package.scala
    66   term.scala
    67   term_xml.scala
    68 )
    69 
    70 
    71 ## diagnostics
    72 
    73 PRG="$(basename "$0")"
    74 
    75 function usage()
    76 {
    77   echo
    78   echo "Usage: isabelle $PRG [OPTIONS]"
    79   echo
    80   echo "  Options are:"
    81   echo "    -f           fresh build"
    82   echo "    -t           test separate compilation of PIDE"
    83   echo
    84   exit 1
    85 }
    86 
    87 function fail()
    88 {
    89   echo "$1" >&2
    90   exit 2
    91 }
    92 
    93 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
    94 
    95 
    96 ## process command line
    97 
    98 # options
    99 
   100 FRESH=""
   101 TEST_PIDE=""
   102 
   103 while getopts "ft" OPT
   104 do
   105   case "$OPT" in
   106     f)
   107       FRESH=true
   108       ;;
   109     t)
   110       TEST_PIDE=true
   111       ;;
   112     \?)
   113       usage
   114       ;;
   115   esac
   116 done
   117 
   118 shift $(($OPTIND - 1))
   119 
   120 
   121 # args
   122 
   123 [ "$#" -ne 0 ] && usage
   124 
   125 
   126 
   127 # build
   128 
   129 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   130 TARGET="$TARGET_DIR/ext/Pure.jar"
   131 
   132 declare -a PIDE_SOURCES=()
   133 declare -a PURE_SOURCES=()
   134 
   135 for DEP in "${SOURCES[@]}"
   136 do
   137   if grep "Module:.*PIDE" "$DEP" >/dev/null
   138   then
   139     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   140   else
   141     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   142   fi
   143 done
   144 
   145 declare -a UPDATED=()
   146 
   147 if [ -n "$FRESH" ]; then
   148   OUTDATED=true
   149 else
   150   OUTDATED=false
   151   if [ ! -e "$TARGET" ]; then
   152     OUTDATED=true
   153   else
   154     for DEP in "${SOURCES[@]}"
   155     do
   156       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   157       [ "$DEP" -nt "$TARGET" ] && {
   158         OUTDATED=true
   159         UPDATED["${#UPDATED[@]}"]="$DEP"
   160       }
   161     done
   162   fi
   163 fi
   164 
   165 if [ "$OUTDATED" = true ]
   166 then
   167   echo "### Building Isabelle/Scala layer ..."
   168 
   169   [ "${#UPDATED[@]}" -gt 0 ] && {
   170     echo "Changed files:"
   171     for FILE in "${UPDATED[@]}"
   172     do
   173       echo "  $FILE"
   174     done
   175   }
   176 
   177   rm -rf classes && mkdir classes
   178 
   179   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   180 
   181   if [ "$TEST_PIDE" = true ]; then
   182     isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   183       fail "Failed to compile PIDE sources"
   184     isabelle_scala scalac $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
   185       fail "Failed to compile Pure sources"
   186   else
   187     isabelle_scala scalac $SCALAC_OPTIONS -classpath classes \
   188       "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   189       fail "Failed to compile sources"
   190   fi
   191 
   192   mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
   193 
   194   pushd classes >/dev/null
   195 
   196   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   197   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   198   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   199 
   200   isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
   201     fail "Failed to produce $TARGET"
   202 
   203   cp "$SCALA_HOME/lib/scala-compiler.jar" \
   204     "$SCALA_HOME/lib/scala-library.jar" \
   205     "$SCALA_HOME/lib/scala-swing.jar" "$TARGET_DIR/ext"
   206 
   207   [ -e "$SCALA_HOME/lib/scala-actors.jar" ] && \
   208     cp "$SCALA_HOME/lib/scala-actors.jar" "$TARGET_DIR/ext"
   209 
   210   popd >/dev/null
   211 
   212   rm -rf classes
   213 fi