simplified build/bootstrap of Isabelle/Scala components -- avoid make;
authorwenzelm
Wed, 06 Jan 2010 20:00:22 +0100
changeset 34282 549969a7f582
parent 34281 eedea6f0b37e
child 34283 7911e83d06c0
simplified build/bootstrap of Isabelle/Scala components -- avoid make;
Admin/build
Isabelle
lib/Tools/scala
src/Pure/IsaMakefile
src/Pure/mk
src/Pure/mk-jars
--- a/Admin/build	Wed Jan 06 18:22:43 2010 +0100
+++ b/Admin/build	Wed Jan 06 20:00:22 2010 +0100
@@ -2,21 +2,12 @@
 #
 # Administrative build for Isabelle source distribution.
 
-## global environment
-
-#paranoia setting for sunbroy
-PATH="/usr/local/dist/DIR/j2sdk1.5.0/bin:$PATH"
-
-PATH="/home/scala/current/bin:$PATH"
-if [ -z "$SCALA_HOME" ]; then
-  export SCALA_HOME="$(dirname "$(dirname "$(type -p scalac)")")"
-fi
-
-
 ## directory layout
 
-ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
-ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
+if [ -z "$ISABELLE_HOME" ]; then
+  ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
+  ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
+fi
 
 
 ## diagnostics
@@ -35,7 +26,7 @@
     all             all modules below
     browser         graph browser (requires jdk)
     doc             documentation (requires latex and rail)
-    jars            Scala/JVM components (requires scala)
+    jars            Scala/JVM components (requires scala in SCALA_HOME)
 
 EOF
   exit 1
@@ -95,14 +86,8 @@
 
 function build_jars ()
 {
-  echo "###"
-  echo "### Building Scala/JVM components ..."
-  echo "###"
-
-  [ -z "$SCALA_HOME" ] && fail "Scala unavailable: unknown SCALA_HOME"
-
   pushd "$ISABELLE_HOME/src/Pure" >/dev/null
-  "$ISABELLE_TOOL" make jars || fail "Failed to build isabelle-scala.jar"
+  "$ISABELLE_TOOL" env ./mk-jars || fail "Failed."
   popd >/dev/null
 }
 
--- a/Isabelle	Wed Jan 06 18:22:43 2010 +0100
+++ b/Isabelle	Wed Jan 06 20:00:22 2010 +0100
@@ -16,12 +16,14 @@
 source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
 
 unset ISABELLE_SETTINGS_PRESENT
+unset ISABELLE_SITE_SETTINGS_PRESENT
 
 
 ## main
 
+[ -e "$ISABELLE_HOME/Admin/build" ] && "$ISABELLE_HOME/Admin/build" jars
+
 CLASSPATH="$(jvmpath "$CLASSPATH")"
-
 exec "$ISABELLE_JAVA" \
   "-Disabelle.home=$(jvmpath "$ISABELLE_HOME")" \
   -jar "$(jvmpath "$ISABELLE_HOME/lib/classes/isabelle-scala.jar")" "$@"
--- a/lib/Tools/scala	Wed Jan 06 18:22:43 2010 +0100
+++ b/lib/Tools/scala	Wed Jan 06 20:00:22 2010 +0100
@@ -4,5 +4,7 @@
 #
 # DESCRIPTION: invoke Scala within the Isabelle environment
 
+[ -e "$ISABELLE_HOME/Admin/build" ] && "$ISABELLE_HOME/Admin/build" jars
+
 CLASSPATH="$(jvmpath "$CLASSPATH")"
 exec "$ISABELLE_SCALA" "$@"
--- a/src/Pure/IsaMakefile	Wed Jan 06 18:22:43 2010 +0100
+++ b/src/Pure/IsaMakefile	Wed Jan 06 20:00:22 2010 +0100
@@ -117,39 +117,3 @@
 clean:
 	@rm -f $(OUT)/Pure $(LOG)/Pure.gz $(OUT)/RAW $(LOG)/RAW.gz \
           $(LOG)/Pure-ProofGeneral.gz
-
-
-## Scala material
-
-SCALA_FILES = Concurrent/future.scala General/download.scala		\
-  General/event_bus.scala General/exn.scala General/linear_set.scala	\
-  General/markup.scala General/position.scala General/scan.scala	\
-  General/swing_thread.scala General/symbol.scala General/xml.scala	\
-  General/yxml.scala Isar/isar_document.scala Isar/outer_keyword.scala	\
-  Isar/outer_lex.scala Isar/outer_parse.scala Isar/outer_syntax.scala	\
-  System/cygwin.scala System/gui_setup.scala				\
-  System/isabelle_process.scala System/isabelle_syntax.scala		\
-  System/isabelle_system.scala System/platform.scala			\
-  System/session_manager.scala System/standard_system.scala		\
-  Thy/completion.scala Thy/html.scala Thy/text_edit.scala		\
-  Thy/thy_header.scala Thy/thy_syntax.scala library.scala
-
-JAR_DIR = $(ISABELLE_HOME)/lib/classes
-PURE_JAR = $(JAR_DIR)/Pure.jar
-FULL_JAR = $(JAR_DIR)/isabelle-scala.jar
-
-jars: $(FULL_JAR)
-
-$(FULL_JAR): $(SCALA_FILES)
-	@rm -rf classes && mkdir classes
-	"$(SCALA_HOME)/bin/scalac" -unchecked -deprecation -d classes -target jvm-1.5 $(SCALA_FILES)
-	@cp $(SCALA_FILES) classes/isabelle
-	@mkdir -p "$(JAR_DIR)"
-	@cd classes; jar cfe `jvmpath "$(PURE_JAR)"` isabelle.GUI_Setup isabelle
-	@cd classes; 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
-	@rm -rf classes
-
-clean-jars:
-	@rm -f "$(PURE_JAR)" "$(FULL_JAR)"
--- a/src/Pure/mk	Wed Jan 06 18:22:43 2010 +0100
+++ b/src/Pure/mk	Wed Jan 06 20:00:22 2010 +0100
@@ -2,9 +2,9 @@
 #
 # Author: Markus Wenzel, TU Muenchen
 #
-# mk - build Pure Isabelle.
+# mk - build Isabelle/Pure.
 #
-# Requires proper Isabelle settings environment (cf. IsaMakefile).
+# Requires proper Isabelle settings environment.
 
 
 ## diagnostics
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/mk-jars	Wed Jan 06 20:00:22 2010 +0100
@@ -0,0 +1,98 @@
+#!/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 "Scala unavailable: unknown SCALA_HOME"
+
+
+## dependencies
+
+declare -a SOURCES=(
+  Concurrent/future.scala
+  General/download.scala
+  General/event_bus.scala
+  General/exn.scala
+  General/linear_set.scala
+  General/markup.scala
+  General/position.scala
+  General/scan.scala
+  General/swing_thread.scala
+  General/symbol.scala
+  General/xml.scala
+  General/yxml.scala
+  Isar/isar_document.scala
+  Isar/outer_keyword.scala
+  Isar/outer_lex.scala
+  Isar/outer_parse.scala
+  Isar/outer_syntax.scala
+  System/cygwin.scala
+  System/gui_setup.scala
+  System/isabelle_process.scala
+  System/isabelle_syntax.scala
+  System/isabelle_system.scala
+  System/platform.scala
+  System/session_manager.scala
+  System/standard_system.scala
+  Thy/completion.scala
+  Thy/html.scala
+  Thy/text_edit.scala
+  Thy/thy_header.scala
+  Thy/thy_syntax.scala
+  library.scala
+)
+
+JAR_DIR="$ISABELLE_HOME/lib/classes"
+PURE_JAR="$JAR_DIR/Pure.jar"
+FULL_JAR="$JAR_DIR/isabelle-scala.jar"
+
+
+## main
+
+OUTDATED=false
+
+for SOURCE in "${SOURCES[@]}"
+do
+  [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
+  for TARGET in "$PURE_JAR" "$FULL_JAR"
+  do
+    [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
+  done
+done
+
+if [ "$OUTDATED" = true ]; then
+  echo "###"
+  echo "### Building Isabelle/Scala components ..."
+  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 "$JAR_DIR" || fail "Failed to create directory $JAR_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