summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-03-25 21:53:58 +0000
committerPaul Phillips <paulp@improving.org>2010-03-25 21:53:58 +0000
commitf427b1e67d63dfe49d8b0dd25265c721ce5851cc (patch)
treed37715706f7df2982b5153af8a98139c06610840 /src
parentaa406f4b8264a17926f3cafdc61010b7210c67b8 (diff)
downloadscala-f427b1e67d63dfe49d8b0dd25265c721ce5851cc.tar.gz
scala-f427b1e67d63dfe49d8b0dd25265c721ce5851cc.tar.bz2
scala-f427b1e67d63dfe49d8b0dd25265c721ce5851cc.zip
Altered classpath behavior when no default is g...
Altered classpath behavior when no default is given. Now in that case the contents of environment variable CLASSPATH will be used as the scala user classpath, and only if that is not present will "." be used. Be advised that there are still various "hand assembled" sorts of classpaths in trunk, and there's not yet any way to ensure they honor this; things which use the normal Settings object should do the right thing. No review.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala3
-rw-r--r--src/compiler/scala/tools/util/PathResolver.scala21
2 files changed, 16 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 0ee0f6f422..f9fd996add 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -19,6 +19,7 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings {
self: MutableSettings =>
import PathResolver.{ Defaults, Environment }
+ import Defaults.{ scalaUserClassPath }
/** Set of settings */
protected lazy val allSettings = HashSet[Setting]()
@@ -37,7 +38,7 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings {
*/
// argfiles is only for the help message
val argfiles = BooleanSetting ("@<file>", "A text file containing compiler arguments (options and source files)")
- val classpath = PathSetting ("-classpath", "path", "Specify where to find user class files", ".") .
+ val classpath = PathSetting ("-classpath", "path", "Specify where to find user class files", scalaUserClassPath) .
withAbbreviation ("-cp")
val d = OutputSetting (outputDirs, ".")
val defines = DefinesSetting()
diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala
index 3f5b7c4d62..d7e420a5c5 100644
--- a/src/compiler/scala/tools/util/PathResolver.scala
+++ b/src/compiler/scala/tools/util/PathResolver.scala
@@ -48,11 +48,11 @@ object PathResolver {
File(url.getFile).parent.path
} getOrElse ""
- // No environment variables are used. It's for the best.
- //
- // def classPathEnv = envOrElse("CLASSPATH", "")
- // def sourcePathEnv = envOrElse("SOURCEPATH", "")
- // def scalaHomeEnv = envOrElse("SCALA_HOME", "")
+ /** Environment variables which java pays attention to so it
+ * seems we do as well.
+ */
+ def classPathEnv = envOrElse("CLASSPATH", "")
+ def sourcePathEnv = envOrElse("SOURCEPATH", "")
def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath)
def javaExtDirs = propOrEmpty("java.ext.dirs")
@@ -83,6 +83,13 @@ object PathResolver {
* to the path resolution specification.
*/
object Defaults {
+ /* Against my better judgment, giving in to martin here and allowing
+ * CLASSPATH as the default if no -cp is given. Only if there is no
+ * command line option or environment variable is "." used.
+ */
+ def scalaUserClassPath = firstNonEmpty(Environment.classPathEnv, ".")
+ def scalaSourcePath = Environment.sourcePathEnv
+
def javaBootClassPath = Environment.javaBootClassPath
def javaUserClassPath = Environment.javaUserClassPath
def javaExtDirs = Environment.javaExtDirs
@@ -189,8 +196,8 @@ class PathResolver(settings: Settings, context: JavaContext) {
def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else ""
def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath)
def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs)
- def userClassPath = cmdLineOrElse("classpath", ".")
- def sourcePath = cmdLineOrElse("sourcepath", "")
+ def userClassPath = cmdLineOrElse("classpath", Defaults.scalaUserClassPath)
+ def sourcePath = cmdLineOrElse("sourcepath", Defaults.scalaSourcePath)
import context._