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