more robust: avoid duplicate classpath entries;
authorwenzelm
Thu, 15 Jul 2021 17:33:06 +0200
changeset 73988 678e1c9eb009
parent 73987 fc363a3b690a
child 73989 842fc354c031
more robust: avoid duplicate classpath entries;
bin/isabelle_java
lib/Tools/java
lib/Tools/scala
lib/Tools/scalac
lib/scripts/getfunctions
lib/scripts/getsettings
src/Pure/Admin/build_release.scala
src/Pure/Admin/other_isabelle.scala
src/Pure/System/scala.scala
--- a/bin/isabelle_java	Thu Jul 15 16:35:45 2021 +0200
+++ b/bin/isabelle_java	Thu Jul 15 17:33:06 2021 +0200
@@ -18,7 +18,7 @@
 
   eval "declare -a JAVA_ARGS=($ISABELLE_JAVA_SYSTEM_OPTIONS $ISABELLE_TOOL_JAVA_OPTIONS)"
 
-  isabelle_setup_classpath
+  classpath "$ISABELLE_SETUP_CLASSPATH"
 
   [ -n "$CLASSPATH" ] && classpath "$CLASSPATH"
 
--- a/lib/Tools/java	Thu Jul 15 16:35:45 2021 +0200
+++ b/lib/Tools/java	Thu Jul 15 17:33:06 2021 +0200
@@ -6,7 +6,8 @@
 
 eval "declare -a JAVA_ARGS=($ISABELLE_JAVA_SYSTEM_OPTIONS)"
 
-isabelle_setup_classpath
+classpath "$ISABELLE_SETUP_CLASSPATH"
+unset ISABELLE_SETUP_CLASSPATH
 
 [ -n "$CLASSPATH" ] && classpath "$CLASSPATH"
 unset CLASSPATH
--- a/lib/Tools/scala	Thu Jul 15 16:35:45 2021 +0200
+++ b/lib/Tools/scala	Thu Jul 15 17:33:06 2021 +0200
@@ -13,6 +13,9 @@
   SCALA_ARGS["${#SCALA_ARGS[@]}"]="-J$ARG"
 done
 
+classpath "$ISABELLE_SETUP_CLASSPATH"
+unset ISABELLE_SETUP_CLASSPATH
+
 [ -n "$CLASSPATH" ] && classpath "$CLASSPATH"
 unset CLASSPATH
 
--- a/lib/Tools/scalac	Thu Jul 15 16:35:45 2021 +0200
+++ b/lib/Tools/scalac	Thu Jul 15 17:33:06 2021 +0200
@@ -6,5 +6,11 @@
 
 isabelle_admin_build jars || exit $?
 
+classpath "$ISABELLE_SETUP_CLASSPATH"
+unset ISABELLE_SETUP_CLASSPATH
+
+[ -n "$CLASSPATH" ] && classpath "$CLASSPATH"
+unset CLASSPATH
+
 isabelle_scala scalac -Dfile.encoding=UTF-8 \
   -classpath "$(platform_path "$ISABELLE_CLASSPATH")" "$@"
--- a/lib/scripts/getfunctions	Thu Jul 15 16:35:45 2021 +0200
+++ b/lib/scripts/getfunctions	Thu Jul 15 17:33:06 2021 +0200
@@ -211,21 +211,12 @@
 }
 export -f isabelle_directory
 
-#setup classpath
-function isabelle_setup_classpath
-{
-  classpath "$(isabelle_java java -classpath "$(platform_path "$ISABELLE_SETUP_JAR")" isabelle.setup.Setup classpath)"
-}
-export -f isabelle_setup_classpath
-
 #administrative build
 function isabelle_admin_build ()
 {
-  {
-    if [ -e "$ISABELLE_HOME/Admin/build" ]; then
-      "$ISABELLE_HOME/Admin/build" "$@"
-    fi
-  } && isabelle_setup_classpath
+  if [ -e "$ISABELLE_HOME/Admin/build" ]; then
+    "$ISABELLE_HOME/Admin/build" "$@"
+  fi
 }
 export -f isabelle_admin_build
 
--- a/lib/scripts/getsettings	Thu Jul 15 16:35:45 2021 +0200
+++ b/lib/scripts/getsettings	Thu Jul 15 17:33:06 2021 +0200
@@ -129,6 +129,8 @@
   export JAVA_HOME="$ISABELLE_JDK_HOME"
 fi
 
+ISABELLE_SETUP_CLASSPATH="$(isabelle_java java -classpath "$(platform_path "$ISABELLE_SETUP_JAR")" isabelle.setup.Setup classpath)"
+
 set +o allexport
 
 fi
--- a/src/Pure/Admin/build_release.scala	Thu Jul 15 16:35:45 2021 +0200
+++ b/src/Pure/Admin/build_release.scala	Thu Jul 15 17:33:06 2021 +0200
@@ -581,12 +581,14 @@
         val classpath: List[Path] =
         {
           val base = isabelle_target.absolute
-          Path.split(other_isabelle.setup_classpath()).map(path =>
+          val classpath1 = Path.split(other_isabelle.getenv("ISABELLE_CLASSPATH"))
+          val classpath2 = Path.split(other_isabelle.getenv("ISABELLE_SETUP_CLASSPATH"))
+          (classpath1 ::: classpath2).map(path =>
           {
             val abs_path = path.absolute
             File.relative_path(base, abs_path) match {
               case Some(rel_path) => rel_path
-              case None => error("Bad ISABELLE_CLASSPATH element: " + abs_path)
+              case None => error("Bad classpath element: " + abs_path)
             }
           })
         }
--- a/src/Pure/Admin/other_isabelle.scala	Thu Jul 15 16:35:45 2021 +0200
+++ b/src/Pure/Admin/other_isabelle.scala	Thu Jul 15 17:33:06 2021 +0200
@@ -57,10 +57,6 @@
   def getenv(name: String): String =
     other_isabelle("getenv -b " + Bash.string(name)).check.out
 
-  def setup_classpath(): String =
-    other_isabelle("env bash -c " +
-      Bash.string("isabelle_setup_classpath && isabelle getenv -b ISABELLE_CLASSPATH")).check.out
-
   val isabelle_home_user: Path = Path.explode(getenv("ISABELLE_HOME_USER"))
 
   val etc: Path = isabelle_home_user + Path.explode("etc")
--- a/src/Pure/System/scala.scala	Thu Jul 15 16:35:45 2021 +0200
+++ b/src/Pure/System/scala.scala	Thu Jul 15 17:33:06 2021 +0200
@@ -80,12 +80,11 @@
   /** compiler **/
 
   def class_path(): List[String] =
-    Library.distinct(
-      for {
-        prop <- List("isabelle.scala.classpath", "java.class.path")
-        elems = System.getProperty(prop, "") if elems.nonEmpty
-        elem <- space_explode(JFile.pathSeparatorChar, elems) if elem.nonEmpty
-      } yield elem)
+    for {
+      prop <- List("isabelle.scala.classpath", "java.class.path")
+      elems = System.getProperty(prop, "") if elems.nonEmpty
+      elem <- space_explode(JFile.pathSeparatorChar, elems) if elem.nonEmpty
+    } yield elem
 
   object Compiler
   {