diff options
Diffstat (limited to 'src')
4 files changed, 39 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala index d8de9527d0..1e5d3c2b66 100644 --- a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala +++ b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala @@ -71,7 +71,10 @@ class ScalacFork extends MatchingTask with ScalacShared with TaskArgs { settings.d = destinationDir compTarget foreach (settings.target = _) - compilationPath foreach (settings.classpath = _) + compilationPath foreach { x => + settings.classpath = x + settings.javaignorecp = true // ensures java classpath will not be used + } sourcePath foreach (settings.sourcepath = _) params foreach (settings.more = _) @@ -106,10 +109,6 @@ class ScalacFork extends MatchingTask with ScalacShared with TaskArgs { java setClasspath compilerPath java setClassname MainClass - // if compilationPath is set, set -Dscala.home so the compilerPath is not - // used by scala - compilationPath foreach (_ => java.createJvmarg() setValue "-Dscala.home=") - // dump the arguments to a file and do "java @file" val tempArgFile = io.File.makeTemp("scalacfork") val tokens = settings.toArgs ++ (includedFiles map (_.getPath)) diff --git a/src/compiler/scala/tools/ant/sabbus/Settings.scala b/src/compiler/scala/tools/ant/sabbus/Settings.scala index 2719196095..45c1b20052 100644 --- a/src/compiler/scala/tools/ant/sabbus/Settings.scala +++ b/src/compiler/scala/tools/ant/sabbus/Settings.scala @@ -64,9 +64,12 @@ class Settings { def more = moreBf.get def more_=(s: String): this.type = { moreBf = Some(s); this } + var javaignorecp: Boolean = false + def toArgs: List[String] = (if (!gBf.isEmpty) "-g:"+g :: Nil else Nil) ::: (if (uncheckedBf) "-unchecked" :: Nil else Nil) ::: + (if (javaignorecp) "-javaignorecp" :: Nil else Nil) ::: (if (!classpathBf.isEmpty) "-classpath" :: classpath.toString :: Nil else Nil) ::: (if (!sourcepathBf.isEmpty) "-sourcepath" :: sourcepath.toString :: Nil else Nil) ::: (if (!sourcedirBf.isEmpty) "-Xsourcedir" :: sourcedir.toString :: Nil else Nil) ::: diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index 69a840cb83..2c3a3a7890 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -256,6 +256,7 @@ class Settings(errorFn: String => Unit) extends ScalacSettings { } override def toString() = "Settings {\n%s}\n" format (userSetSettings map (" " + _ + "\n") mkString) + def toConciseString = userSetSettings.mkString("(", " ", ")") } object Settings { @@ -830,6 +831,8 @@ trait ScalacSettings { val extdirs = PathSetting ("-extdirs", "dirs", "Override location of installed extensions", Defaults.scalaExtDirs) val javabootclasspath = PathSetting ("-javabootclasspath", "path", "Override java boot classpath.", Defaults.javaBootClassPath) val javaextdirs = PathSetting ("-javaextdirs", "path", "Override java extdirs classpath.", Defaults.javaExtDirs) + /** This one is most likely temporary, but so helpful while I try to get an iron grip on the classpath. */ + val javaignorecp = BooleanSetting ("-javaignorecp", "scala will not use java's -classpath no matter what.") val outdir = OutputSetting (outputDirs, ".") val sourcepath = StringSetting ("-sourcepath", "path", "Specify where to find input source files", "") diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index 5c6bd2c884..cadd4d2051 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -52,23 +52,35 @@ object PathResolver { def sourcePathEnv = envOrElse("SOURCEPATH", "") // not used def scalaHomeEnv = envOrElse("SCALA_HOME", "") // not used def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath) - def javaExtDirs = propOrElse("java.ext.dirs", "") + def javaExtDirs = propOrEmpty("java.ext.dirs") def javaUserClassPath = propOrElse("java.class.path", classPathEnv) - def scalaExtDirs = propOrElse("scala.ext.dirs", "") - - def scalaHome = propOrElse("scala.home", null) - def scalaHomeIsSet = scalaHome != null - def scalaAutodetect = propIsSet("scala.auto") && !propIsSet("scala.noauto") + def scalaExtDirs = propOrEmpty("scala.ext.dirs") + + def scalaHome = propOrEmpty("scala.home") + + /** I have distilled everyone's classpath hopes and dreams into the + * question of how to resolve this boolean. Right at this moment if I + * do anything but default to true right here, partest chokes. I'm + * steadily reworking all the places partest gets its hands on the + * classpath so eventually I'll be able to remedy that, at which point + * my current plan is to have this default to false unless some + * property or command line option is supplied. This is negotiable, + * but at this point I can say with confidence that less magic and + * less autodetection is more better. + */ + def useJavaClassPath = true + // hypothetically: + // def useJavaClassPath = propIsSet("scala.auto.class.path") override def toString = """ |object Environment { - | scalaHome = %s (autodetect = %s) + | scalaHome = %s (useJavaClassPath = %s) | javaBootClassPath = <%d chars> | javaExtDirs = %s | javaUserClassPath = %s | scalaExtDirs = %s |}""".trim.stripMargin.format( - scalaHome, scalaAutodetect, + scalaHome, useJavaClassPath, javaBootClassPath.length, ppcp(javaExtDirs), ppcp(javaUserClassPath), @@ -81,10 +93,10 @@ object PathResolver { */ object Defaults { def javaBootClassPath = Environment.javaBootClassPath - def javaUserClassPath = firstNonEmpty(Environment.javaUserClassPath, Environment.classPathEnv) + def javaUserClassPath = Environment.javaUserClassPath def javaExtDirs = Environment.javaExtDirs - def scalaHome = Option(Environment.scalaHome) getOrElse "" + def scalaHome = Environment.scalaHome def scalaHomeDir = Directory(scalaHome) def scalaHomeExists = scalaHomeDir.isDirectory def scalaLibDir = Directory(scalaHomeDir / "lib") @@ -174,6 +186,8 @@ class PathResolver(settings: Settings, context: JavaContext) { case "sourcepath" => settings.sourcepath.value } + private def useJavaClassPath = !settings.javaignorecp.value && Environment.useJavaClassPath + /** Calculated values based on any given command line options, falling back on * those in Defaults. */ @@ -181,7 +195,7 @@ class PathResolver(settings: Settings, context: JavaContext) { def scalaHome = Defaults.scalaHome def javaBootClassPath = cmdLineOrElse("javabootclasspath", Defaults.javaBootClassPath) def javaExtDirs = cmdLineOrElse("javaextdirs", Defaults.javaExtDirs) - def javaUserClassPath = if (Environment.scalaHomeIsSet) "" else Defaults.javaUserClassPath + def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else "" def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath) def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs) def userClassPath = cmdLineOrElse("classpath", ".") @@ -208,6 +222,7 @@ class PathResolver(settings: Settings, context: JavaContext) { | javaBootClassPath = %s | javaExtDirs = %s | javaUserClassPath = %s + | useJavaClassPath = %s | scalaBootClassPath = %s | scalaExtDirs = %s | userClassPath = %s @@ -215,6 +230,7 @@ class PathResolver(settings: Settings, context: JavaContext) { |}""".trim.stripMargin.format( scalaHome, ppcp(javaBootClassPath), ppcp(javaExtDirs), ppcp(javaUserClassPath), + useJavaClassPath, ppcp(scalaBootClassPath), ppcp(scalaExtDirs), ppcp(userClassPath), ppcp(sourcePath) ) @@ -225,8 +241,8 @@ class PathResolver(settings: Settings, context: JavaContext) { lazy val result = { val cp = new JavaClassPath(containers, context) if (settings.Ylogcp.value) { - Console.println("Classpath built from " + settings) - Console.println("And Environment: " + PathResolver.Environment) + Console.println("Classpath built from " + settings.toConciseString) + Console.println("Defaults: " + PathResolver.Defaults) val xs = (Calculated.basis drop 2).flatten.distinct println("After java boot/extdirs classpath has %d entries:" format xs.size) |