src/Pure/build-jars
author blanchet
Mon, 06 Dec 2010 13:29:23 +0100
changeset 40996 63112be4a469
parent 40393 2bb7ec08574a
child 42720 caa4f1279154
permissions -rwxr-xr-x
added "Neq" operator to monotonicity inference module

#!/usr/bin/env bash
#
# Author: Makarius
#
# mk-jars - build Isabelle/Scala
#
# Requires proper Isabelle settings environment.


## diagnostics

function fail()
{
  echo "$1" >&2
  exit 2
}

[ -n "$ISABELLE_HOME" ] || fail "Missing Isabelle settings environment"
[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"


## dependencies

declare -a SOURCES=(
  Concurrent/future.scala
  Concurrent/simple_thread.scala
  Concurrent/volatile.scala
  General/exn.scala
  General/timing.scala
  General/linear_set.scala
  General/markup.scala
  General/position.scala
  General/pretty.scala
  General/scan.scala
  General/sha1.scala
  General/symbol.scala
  General/xml.scala
  General/xml_data.scala
  General/yxml.scala
  Isar/keyword.scala
  Isar/outer_syntax.scala
  Isar/parse.scala
  Isar/token.scala
  PIDE/command.scala
  PIDE/document.scala
  PIDE/isar_document.scala
  PIDE/markup_tree.scala
  PIDE/text.scala
  System/cygwin.scala
  System/download.scala
  System/event_bus.scala
  System/gui_setup.scala
  System/isabelle_process.scala
  System/isabelle_syntax.scala
  System/isabelle_system.scala
  System/platform.scala
  System/session.scala
  System/session_manager.scala
  System/standard_system.scala
  System/swing_thread.scala
  Thy/completion.scala
  Thy/html.scala
  Thy/thy_header.scala
  Thy/thy_syntax.scala
  library.scala
)

TARGET_DIR="$ISABELLE_HOME/lib/classes"
PURE_JAR="$TARGET_DIR/Pure.jar"
FULL_JAR="$TARGET_DIR/isabelle-scala.jar"

declare -a TARGETS=("$PURE_JAR" "$FULL_JAR")


## main

OUTDATED=false

for SOURCE in "${SOURCES[@]}"
do
  [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
  for TARGET in "${TARGETS[@]}"
  do
    [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
  done
done

if [ "$OUTDATED" = true ]
then
  echo "###"
  echo "### Building Isabelle/Scala layer ..."
  echo "###"

  rm -rf classes && mkdir classes
  "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
    fail "Failed to compile sources"
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
  (
    cd classes
    jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
      fail "Failed to produce $PURE_JAR"

    cp "$SCALA_HOME/lib/scala-swing.jar" .
    jar xf scala-swing.jar

    cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
    jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
      fail "Failed to produce $FULL_JAR"
  )
  rm -rf classes
fi