more robust command invocation via ISABELLE_JDK_HOME or SCALA_HOME (NB: bash exec requires genuine executable, not function);
authorwenzelm
Mon Mar 26 16:25:08 2012 +0200 (2012-03-26)
changeset 471151a05adae1cc9
parent 47114 7c9e31ffcd9e
child 47118 2fe7a42ece1d
more robust command invocation via ISABELLE_JDK_HOME or SCALA_HOME (NB: bash exec requires genuine executable, not function);
Admin/build
lib/Tools/java
lib/Tools/scala
lib/Tools/scalac
lib/browser/build
lib/scripts/getsettings
src/Pure/build-jars
src/Tools/JVM/java_ext_dirs
src/Tools/jEdit/lib/Tools/jedit
     1.1 --- a/Admin/build	Mon Mar 26 15:38:09 2012 +0200
     1.2 +++ b/Admin/build	Mon Mar 26 16:25:08 2012 +0200
     1.3 @@ -27,7 +27,7 @@
     1.4      browser         graph browser (requires jdk)
     1.5      doc             documentation (requires latex and rail)
     1.6      doc-src         documentation sources from Isabelle theories
     1.7 -    jars            Isabelle/Scala layer (requires Scala in \$SCALA_HOME)
     1.8 +    jars            Isabelle/Scala layer (requires \$ISABELLE_JDK_HOME and \$SCALA_HOME)
     1.9      jars_fresh      fresh build of jars
    1.10  
    1.11  EOF
     2.1 --- a/lib/Tools/java	Mon Mar 26 15:38:09 2012 +0200
     2.2 +++ b/lib/Tools/java	Mon Mar 26 16:25:08 2012 +0200
     2.3 @@ -6,21 +6,12 @@
     2.4  
     2.5  CLASSPATH="$(jvmpath "$CLASSPATH")"
     2.6  
     2.7 -JAVA_EXE="$ISABELLE_JDK_HOME/bin/java"
     2.8 -
     2.9 -if "$JAVA_EXE" -version >/dev/null 2>/dev/null; then
    2.10 -  :
    2.11 -else
    2.12 -  echo "Bad Java executable: \"$JAVA_EXE\"" >&2
    2.13 -  exit 2
    2.14 -fi
    2.15 -
    2.16 -if "$JAVA_EXE" -server >/dev/null 2>/dev/null; then
    2.17 +if isabelle_jdk java -server >/dev/null 2>/dev/null; then
    2.18    SERVER="-server"
    2.19  else
    2.20    SERVER=""
    2.21  fi
    2.22  
    2.23 -exec "$JAVA_EXE" -Dfile.encoding=UTF-8 $SERVER \
    2.24 +exec "$ISABELLE_JDK_HOME/bin/java" -Dfile.encoding=UTF-8 $SERVER \
    2.25    "-Djava.ext.dirs=$("$ISABELLE_HOME/src/Tools/JVM/java_ext_dirs")" "$@"
    2.26  
     3.1 --- a/lib/Tools/scala	Mon Mar 26 15:38:09 2012 +0200
     3.2 +++ b/lib/Tools/scala	Mon Mar 26 16:25:08 2012 +0200
     3.3 @@ -4,10 +4,8 @@
     3.4  #
     3.5  # DESCRIPTION: invoke Scala within the Isabelle environment
     3.6  
     3.7 -[ -z "$SCALA_HOME" ] && { echo "Unknown SCALA_HOME -- Scala unavailable"; exit 2; }
     3.8 -
     3.9  [ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
    3.10  
    3.11  CLASSPATH="$(jvmpath "$CLASSPATH")"
    3.12 -exec "$SCALA_HOME/bin/scala" -Dfile.encoding=UTF-8 \
    3.13 +isabelle_scala scala -Dfile.encoding=UTF-8 \
    3.14    "-Djava.ext.dirs=$("$ISABELLE_HOME/src/Tools/JVM/java_ext_dirs")" "$@"
     4.1 --- a/lib/Tools/scalac	Mon Mar 26 15:38:09 2012 +0200
     4.2 +++ b/lib/Tools/scalac	Mon Mar 26 16:25:08 2012 +0200
     4.3 @@ -4,10 +4,8 @@
     4.4  #
     4.5  # DESCRIPTION: invoke Scala compiler within the Isabelle environment
     4.6  
     4.7 -[ -z "$SCALA_HOME" ] && { echo "Unknown SCALA_HOME -- Scala unavailable"; exit 2; }
     4.8 -
     4.9  [ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
    4.10  
    4.11  CLASSPATH="$(jvmpath "$CLASSPATH")"
    4.12 -exec "$SCALA_HOME/bin/scalac" -Dfile.encoding=UTF-8 \
    4.13 +isabelle_scala scalac -Dfile.encoding=UTF-8 \
    4.14    "-Djava.ext.dirs=$("$ISABELLE_HOME/src/Tools/JVM/java_ext_dirs")" "$@"
     5.1 --- a/lib/browser/build	Mon Mar 26 15:38:09 2012 +0200
     5.2 +++ b/lib/browser/build	Mon Mar 26 16:25:08 2012 +0200
     5.3 @@ -65,9 +65,9 @@
     5.4  
     5.5    rm -rf classes && mkdir classes
     5.6  
     5.7 -  "$ISABELLE_JDK_HOME/bin/javac" -d classes -source 1.4 "${SOURCES[@]}" || \
     5.8 +  isabelle_jdk javac -d classes -source 1.4 "${SOURCES[@]}" || \
     5.9      fail "Failed to compile sources"
    5.10 -  "$ISABELLE_JDK_HOME/bin/jar" cf "$(jvmpath "$TARGET")" -C classes . ||
    5.11 +  isabelle_jdk jar cf "$(jvmpath "$TARGET")" -C classes . ||
    5.12      fail "Failed to produce $TARGET"
    5.13  
    5.14    rm -rf classes
     6.1 --- a/lib/scripts/getsettings	Mon Mar 26 15:38:09 2012 +0200
     6.2 +++ b/lib/scripts/getsettings	Mon Mar 26 16:25:08 2012 +0200
     6.3 @@ -89,6 +89,22 @@
     6.4    done
     6.5  }
     6.6  
     6.7 +#robust invocation via ISABELLE_JDK_HOME
     6.8 +function isabelle_jdk () {
     6.9 +  [ -z "$ISABELLE_JDK_HOME" ] && \
    6.10 +    { echo "Unknown ISABELLE_JDK_HOME -- Java tools unavailable"; exit 2; }
    6.11 +  local PRG="$1"; shift
    6.12 +  "$ISABELLE_JDK_HOME/bin/$PRG" "$@"
    6.13 +}
    6.14 +
    6.15 +#robust invocation via SCALA_HOME
    6.16 +function isabelle_scala () {
    6.17 +  [ -z "$SCALA_HOME" ] && \
    6.18 +    { echo "Unknown SCALA_HOME -- Scala unavailable"; exit 2; }
    6.19 +  local PRG="$1"; shift
    6.20 +  "$SCALA_HOME/bin/$PRG" "$@"
    6.21 +}
    6.22 +
    6.23  #CLASSPATH convenience
    6.24  function classpath () {
    6.25    for X in "$@"
     7.1 --- a/src/Pure/build-jars	Mon Mar 26 15:38:09 2012 +0200
     7.2 +++ b/src/Pure/build-jars	Mon Mar 26 16:25:08 2012 +0200
     7.3 @@ -88,7 +88,6 @@
     7.4  }
     7.5  
     7.6  [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
     7.7 -[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
     7.8  
     7.9  
    7.10  ## process command line
    7.11 @@ -172,10 +171,10 @@
    7.12  
    7.13    SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
    7.14  
    7.15 -  "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
    7.16 +  isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
    7.17      fail "Failed to compile PIDE sources"
    7.18  
    7.19 -  "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
    7.20 +  isabelle_scala scalac $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
    7.21      fail "Failed to compile Pure sources"
    7.22  
    7.23    mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
    7.24 @@ -186,7 +185,7 @@
    7.25    mkdir -p "$(dirname "$CHARSET_SERVICE")"
    7.26    echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
    7.27  
    7.28 -  "$ISABELLE_JDK_HOME/bin/jar" cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
    7.29 +  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
    7.30      fail "Failed to produce $TARGET"
    7.31  
    7.32    cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
     8.1 --- a/src/Tools/JVM/java_ext_dirs	Mon Mar 26 15:38:09 2012 +0200
     8.2 +++ b/src/Tools/JVM/java_ext_dirs	Mon Mar 26 16:25:08 2012 +0200
     8.3 @@ -17,7 +17,7 @@
     8.4  
     8.5  ## main
     8.6  
     8.7 -exec "$ISABELLE_JDK_HOME/bin/java" \
     8.8 +isabelle_jdk java \
     8.9    -classpath "$(jvmpath "$ISABELLE_HOME/src/Tools/JVM/java_ext_dirs.jar")" \
    8.10    isabelle.Java_Ext_Dirs "$(jvmpath "$ISABELLE_HOME/lib/classes/ext")"
    8.11  
     9.1 --- a/src/Tools/jEdit/lib/Tools/jedit	Mon Mar 26 15:38:09 2012 +0200
     9.2 +++ b/src/Tools/jEdit/lib/Tools/jedit	Mon Mar 26 16:25:08 2012 +0200
     9.3 @@ -248,7 +248,7 @@
     9.4    ) || fail "Failed to compile sources"
     9.5  
     9.6    cd dist/classes
     9.7 -  "$ISABELLE_JDK_HOME/bin/jar" cf "../jars/Isabelle-jEdit.jar" * || failed
     9.8 +  isabelle_jdk jar cf "../jars/Isabelle-jEdit.jar" * || failed
     9.9    cd ../..
    9.10    rm -rf dist/classes
    9.11  fi