--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Tools/jEdit/jedit_build/Tools/jedit Sat May 21 00:01:15 2011 +0200
@@ -0,0 +1,139 @@
+#!/usr/bin/env bash
+#
+# Author: Makarius
+#
+# DESCRIPTION: build and run Isabelle/jEdit on the spot
+
+## diagnostics
+
+function fail()
+{
+ echo "$1" >&2
+ exit 2
+}
+
+function failed()
+{
+ fail "Failed!"
+}
+
+
+## dependencies
+
+[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
+[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
+
+[ -z "$ISABELLE_JEDIT_BUILD_HOME" ] && \
+ fail "Unknown ISABELLE_JEDIT_BUILD_HOME -- missing auxiliary component"
+
+[ -e "$ISABELLE_HOME/Admin/build" ] && \
+ { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
+
+
+# sources
+
+SRC_DIR="$ISABELLE_HOME/src/Tools/jEdit"
+
+declare -a SOURCES=(
+ "$SRC_DIR/src/jedit/dockable.scala"
+ "$SRC_DIR/src/jedit/document_model.scala"
+ "$SRC_DIR/src/jedit/document_view.scala"
+ "$SRC_DIR/src/jedit/html_panel.scala"
+ "$SRC_DIR/src/jedit/isabelle_encoding.scala"
+ "$SRC_DIR/src/jedit/isabelle_hyperlinks.scala"
+ "$SRC_DIR/src/jedit/isabelle_markup.scala"
+ "$SRC_DIR/src/jedit/isabelle_options.scala"
+ "$SRC_DIR/src/jedit/isabelle_sidekick.scala"
+ "$SRC_DIR/src/jedit/output_dockable.scala"
+ "$SRC_DIR/src/jedit/plugin.scala"
+ "$SRC_DIR/src/jedit/protocol_dockable.scala"
+ "$SRC_DIR/src/jedit/raw_output_dockable.scala"
+ "$SRC_DIR/src/jedit/scala_console.scala"
+ "$SRC_DIR/src/jedit/session_dockable.scala"
+)
+
+declare -a PLUGIN_FILES=(
+ "$SRC_DIR/plugin/actions.xml"
+ "$SRC_DIR/plugin/dockables.xml"
+ "$SRC_DIR/plugin/Isabelle.props"
+ "$SRC_DIR/plugin/services.xml"
+)
+
+JEDIT_JAR="$ISABELLE_JEDIT_BUILD_HOME/contrib/$ISABELLE_JEDIT_BUILD_VERSION/jedit.jar"
+
+JEDIT_JARS=(
+ "$ISABELLE_JEDIT_BUILD_HOME/contrib/Console.jar"
+ "$ISABELLE_JEDIT_BUILD_HOME/contrib/ErrorList.jar"
+ "$ISABELLE_JEDIT_BUILD_HOME/contrib/Hyperlinks.jar"
+ "$ISABELLE_JEDIT_BUILD_HOME/contrib/SideKick.jar"
+ "$ISABELLE_JEDIT_BUILD_HOME/contrib/cobra.jar"
+ "$ISABELLE_JEDIT_BUILD_HOME/contrib/js.jar"
+)
+
+SCALA_JARS=(
+ "$SCALA_HOME/lib/scala-compiler.jar"
+ "$SCALA_HOME/lib/scala-library.jar"
+ "$SCALA_HOME/lib/scala-swing.jar"
+)
+
+
+# target
+
+TARGET_DIR="$ISABELLE_JEDIT_BUILD_HOME/${ISABELLE_JEDIT_BUILD_VERSION}_Isabelle-$("$ISABELLE_TOOL" version -i)"
+TARGET="$TARGET_DIR/jars/Isabelle-jEdit.jar"
+
+OUTDATED=false
+for SOURCE in "${SOURCES[@]}" "${PLUGIN_FILES[@]}" "$JEDIT_JAR" "${JEDIT_JARS[@]}"
+do
+ [ ! -e "$SOURCE" ] && fail "Missing file: $SOURCE"
+ [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
+done
+
+
+## main
+
+if [ "$OUTDATED" = true ]
+then
+ echo "###"
+ echo "### Building Isabelle/jEdit ..."
+ echo "###"
+
+ rm -rf "$TARGET_DIR" || failed
+ mkdir -p "$TARGET_DIR" "$TARGET_DIR/classes" || failed
+ cp -a "$ISABELLE_JEDIT_BUILD_HOME/contrib/$ISABELLE_JEDIT_BUILD_VERSION/." "$TARGET_DIR/."
+
+ cp -a "${PLUGIN_FILES[@]}" "$TARGET_DIR/classes/."
+ cp -a "$SRC_DIR/dist-template/." "$TARGET_DIR/."
+ cp -a "$SRC_DIR/README" "$TARGET_DIR/."
+
+ perl -i -e 'while (<>) { if (m/NAME="javacc"/) {
+ print qq,<MODE NAME="isabelle" FILE="isabelle.xml" FILE_NAME_GLOB="*.thy"/>\n\n,;
+ print qq,<MODE NAME="isabelle-session" FILE="isabelle-session.xml" FILE_NAME_GLOB="session.root"/>\n\n,; }
+ print; }' "$TARGET_DIR/modes/catalog"
+
+ (
+ for JAR in "$JEDIT_JAR" "${JEDIT_JARS[@]}" "$SCALA_HOME/lib/scala-compiler.jar"
+ do
+ CLASSPATH="$CLASSPATH:$JAR"
+ done
+
+ cp -a "${JEDIT_JARS[@]}" "${SCALA_JARS[@]}" "$ISABELLE_HOME/lib/classes/Pure.jar" \
+ "$TARGET_DIR/jars/." || failed
+
+ CLASSPATH="$(jvmpath "$CLASSPATH")"
+ "$SCALA_HOME/bin/scalac" -unchecked -deprecation \
+ -d "$TARGET_DIR/classes" -target:jvm-1.5 "${SOURCES[@]}" || \
+ fail "Failed to compile sources"
+
+ cd "$TARGET_DIR/classes"
+ jar cf "../jars/Isabelle-jEdit.jar" * || failed
+ cd ..
+ rm -rf classes
+ )
+fi
+
+set -o allexport
+init_component "$TARGET_DIR"
+set +o allexport
+
+exec "$TARGET_DIR/lib/Tools/jedit" "$@"