summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/CompileClient.scala48
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala42
-rw-r--r--src/library/scala/util/Properties.scala1
3 files changed, 26 insertions, 65 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala
index 60215719bf..7c639e013b 100644
--- a/src/compiler/scala/tools/nsc/CompileClient.scala
+++ b/src/compiler/scala/tools/nsc/CompileClient.scala
@@ -29,13 +29,14 @@ class StandardCompileClient {
def absFileNames(paths: String) = {
val sep = File.pathSeparator
val pathsList = paths.split(sep).toList
- pathsList.map(absFileName).mkString("", sep, "")
+ pathsList map absFileName mkString sep
}
protected def normalize(args: Array[String]): (String, String) = {
- var i = 0
+ var i = 0
val vmArgs = new StringBuilder
var serverAdr = ""
+
while (i < args.length) {
val arg = args(i)
if (fileEndings exists(arg endsWith _)) {
@@ -52,18 +53,17 @@ class StandardCompileClient {
shutdown = true
}
i += 1
+
if (i < args.length) {
- if (arg == "-classpath" ||
- arg == "-sourcepath" ||
- arg == "-bootclasspath" ||
- arg == "-extdirs" ||
- arg == "-d") {
- args(i) = absFileNames(args(i))
- i += 1
- } else if (arg == "-server") {
- serverAdr = args(i)
- args(i-1) = ""
- args(i) = ""
+ arg match {
+ case "-classpath" | "-sourcepath" | "-bootclasspath" | "-extdirs" | "-d" =>
+ args(i) = absFileNames(args(i))
+ i += 1
+ case "-server" =>
+ serverAdr = args(i)
+ args(i-1) = ""
+ args(i) = ""
+ case _ =>
}
}
}
@@ -72,13 +72,9 @@ class StandardCompileClient {
// used by class ant.FastScalac to skip exit statement in Ant.
def main0(args0: Array[String]): Int = {
- val args =
- if (args0.exists(arg => arg == "-d"))
- args0
- else
- ("-d" :: "." :: args0.toList).toArray
-
+ val args = if (args0 contains "-d") args0 else Array("-d", ".") ++ args0
val (vmArgs, serverAdr) = normalize(args)
+
if (version) {
Console.println(versionMsg)
return 0
@@ -109,21 +105,13 @@ class StandardCompileClient {
Console.println(fromServer)
fromServer = in.readLine()
}
- in.close()
- out.close()
- socket.close()
+ in.close ; out.close ; socket.close
}
if (sawerror) 1 else 0
}
- def main(args: Array[String]) {
- try {
- val status = main0(args)
- exit(status)
- } catch {
- case e: Exception => exit(1)
- }
- }
+ def main(args: Array[String]): Unit =
+ exit(try main0(args) catch { case e: Exception => 1 })
}
diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala
index c22181eabf..1a0fc7d877 100644
--- a/src/compiler/scala/tools/nsc/CompileSocket.scala
+++ b/src/compiler/scala/tools/nsc/CompileSocket.scala
@@ -58,43 +58,15 @@ class CompileSocket {
/** A temporary directory to use */
val tmpDir = {
- val totry = List(
- ("scala.home", List("var", "scala-devel")),
- ("java.io.tmpdir", List("scala-devel")),
- ("user.home", List("tmp")))
-
- /** Expand a property-extensions pair into a complete File object */
- def expand(trial: (String, List[String])): Option[File] = {
- val (topdirProp, extensions) = trial
- val topdir = System.getProperty(topdirProp)
- if (topdir eq null)
- return None
-
- val fulldir =
- extensions.foldLeft[File](new File(topdir))(
- (dir,ext) => new File(dir, ext))
-
- Some(fulldir)
- }
+ val udir = Option(Properties.userName) getOrElse "shared"
+ val f = (scala.io.File(Properties.tmpDir) / "scala-devel" / udir).file
+ f.mkdirs()
- /** Try to create directory f, and then see if it can
- * be written into. */
- def isDirWritable(f: File): Boolean = {
- f.mkdirs()
- f.isDirectory && f.canWrite
+ if (f.isDirectory && f.canWrite) {
+ info("[Temp directory: " + f + "]")
+ f
}
-
- def findTmpDir(): File = {
- for (trial <- totry) expand(trial) match {
- case Some(dir) if isDirWritable(dir) =>
- info("[Temp directory: " + dir + "]")
- return dir
- case _ =>
- }
- fatal("Could not find a directory for temporary files")
- }
-
- findTmpDir()
+ else fatal("Could not find a directory for temporary files")
}
/* A directory holding port identification files */
diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala
index fb4ecbbd90..0f9e30621e 100644
--- a/src/library/scala/util/Properties.scala
+++ b/src/library/scala/util/Properties.scala
@@ -72,6 +72,7 @@ private[scala] trait PropertiesTrait
val javaVmInfo = sysprop("java.vm.info")
val javaVersion = sysprop("java.version")
val tmpDir = sysprop("java.io.tmpdir")
+ val userName = sysprop("user.name")
val scalaHome = sysprop("scala.home", null) // XXX places do null checks...
// provide a main method so version info can be obtained by running this