summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/settings/FscSettings.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-03-27 23:27:05 +0000
committerPaul Phillips <paulp@improving.org>2011-03-27 23:27:05 +0000
commit4d25cc33ee101708c812889a343535f610becc71 (patch)
tree61b5b34e54e4e1644cff9fc6830a270af9ff1784 /src/compiler/scala/tools/nsc/settings/FscSettings.scala
parentc17e46682a9b42eaf4d33d9f60b50c826ab4009e (diff)
downloadscala-4d25cc33ee101708c812889a343535f610becc71.tar.gz
scala-4d25cc33ee101708c812889a343535f610becc71.tar.bz2
scala-4d25cc33ee101708c812889a343535f610becc71.zip
Trying to get fsc doing the right thing with re...
Trying to get fsc doing the right thing with respect to absolute and relative paths. My knowledge of the problem had heretofore been second hand, and my understanding of it incomplete. The real problem I have determined is that there are a bunch of different things which go wrong if relative paths start being resolved from a different base, each of which needs custom handling. classpath-style options, e.g. fsc -cp ../foo.jar path-style options, e.g. fsc -d ../mydir file arguments, e.g. fsc ../foo.scala So it was more work than I had realized, or I probably wouldn't have even touched it. But now it seems to be working as one would want. I also poured some readability onto the fsc help output. Closes #4395, no review, but community input would be great.
Diffstat (limited to 'src/compiler/scala/tools/nsc/settings/FscSettings.scala')
-rw-r--r--src/compiler/scala/tools/nsc/settings/FscSettings.scala37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/FscSettings.scala b/src/compiler/scala/tools/nsc/settings/FscSettings.scala
index a219148b16..bb62750026 100644
--- a/src/compiler/scala/tools/nsc/settings/FscSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/FscSettings.scala
@@ -8,28 +8,45 @@ package nsc
package settings
import util.ClassPath
+import io.{ Directory, Path, AbstractFile }
class FscSettings(error: String => Unit) extends Settings(error) {
outer =>
- def this() = this(Console.println)
+ locally {
+ disable(prompt)
+ disable(resident)
+ }
+ val currentDir = StringSetting ("-current-dir", "path", "Base directory for resolving relative paths", "").internalOnly()
val reset = BooleanSetting("-reset", "Reset compile server caches")
val shutdown = BooleanSetting("-shutdown", "Shutdown compile server")
val server = StringSetting ("-server", "hostname:portnumber", "Specify compile server socket", "")
- val preferIPv4 = BooleanSetting("-ipv4", "Use IPv4 rather than IPv6 for the server socket")
- val absClasspath = BooleanSetting("-absolute-cp", "Make classpath elements absolute paths before sending to server") .
- withPostSetHook (_ => absolutizeClasspath())
+ val preferIPv4 = BooleanSetting("-ipv4", "Use IPv4 rather than IPv6 for the server socket")
val idleMins = IntSetting ("-max-idle", "Set idle timeout in minutes for fsc (use 0 for no timeout)",
30, Some(0, Int.MaxValue), (_: String) => None)
- disable(prompt)
- disable(resident)
+ // For improved help output, separating fsc options from the others.
+ def fscSpecific = Set[Settings#Setting](
+ currentDir, reset, shutdown, server, preferIPv4, idleMins
+ )
+ val isFscSpecific: String => Boolean = fscSpecific map (_.name)
+
+ /** If a setting (other than a PathSetting) represents a path or paths.
+ * For use in absolutization.
+ */
+ private def holdsPath = Set[Settings#Setting](
+ d, dependencyfile, pluginsDir, Ygenjavap
+ )
- // Make the classpath absolute: for going from client to server.
- private def absolutizeClasspath() {
- userSetSettings collect {
- case x: PathSetting => x.value = ClassPath.makeAbsolute(x.value)
+ /** All user set settings rewritten with absolute paths. */
+ def absolutize(root: Path) {
+ def rewrite(p: String) = (root resolve Path(p)).normalize.path
+ userSetSettings foreach {
+ case p: OutputSetting => p.outputDirs setSingleOutput AbstractFile.getDirectory(rewrite(p.value))
+ case p: PathSetting => p.value = ClassPath.map(p.value, rewrite)
+ case p: StringSetting => if (holdsPath(p)) p.value = rewrite(p.value)
+ case _ => ()
}
}
}