summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/CompileClient.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-02-10 19:51:38 +0000
committerPaul Phillips <paulp@improving.org>2010-02-10 19:51:38 +0000
commit6e76af56f708d345bda2fff580634107945ef3fb (patch)
tree563058a03d54463fbe9139e8f9f74db23a944400 /src/compiler/scala/tools/nsc/CompileClient.scala
parent06ae221de943d7258dfa2ffcbc6c59fe9493497f (diff)
downloadscala-6e76af56f708d345bda2fff580634107945ef3fb.tar.gz
scala-6e76af56f708d345bda2fff580634107945ef3fb.tar.bz2
scala-6e76af56f708d345bda2fff580634107945ef3fb.zip
More work on classpaths.
to have command line options following source files, at the price of temporarily breaking tools/pathResolver. Working my way through all the usages of classpath in trunk zeroing in on fully consistent handling. Review by community.
Diffstat (limited to 'src/compiler/scala/tools/nsc/CompileClient.scala')
-rw-r--r--src/compiler/scala/tools/nsc/CompileClient.scala56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala
index d8c8caac05..4b387298f4 100644
--- a/src/compiler/scala/tools/nsc/CompileClient.scala
+++ b/src/compiler/scala/tools/nsc/CompileClient.scala
@@ -76,36 +76,40 @@ class StandardCompileClient {
val (vmArgs, serverAdr) = normalize(args)
if (version) {
- Console.println(versionMsg)
+ Console println versionMsg
return 0
}
if (verbose) {
- Console.println("[Server arguments: " + args.mkString("", " ", "]"))
- Console.println("[VM arguments: " + vmArgs + "]")
+ Console println args.mkString("[Server arguments: ", " ", "]")
+ Console println "[VM arguments: %s]".format(vmArgs)
}
- val socket = if (serverAdr == "") compileSocket.getOrCreateSocket(vmArgs, !shutdown)
- else compileSocket.getSocket(serverAdr)
- var sawerror = false
- if (socket eq null) {
- if (shutdown) {
- Console.println("[No compilation server running.]")
- } else {
- Console.println("Compilation failed.")
- sawerror = true
- }
- } else {
- val out = new PrintWriter(socket.getOutputStream(), true)
- val in = new BufferedReader(new InputStreamReader(socket.getInputStream()))
- out.println(compileSocket.getPassword(socket.getPort()))
- out.println(args.mkString("", "\0", ""))
- var fromServer = in.readLine()
- while (fromServer ne null) {
- if (compileSocket.errorPattern.matcher(fromServer).matches)
- sawerror = true
- Console.println(fromServer)
- fromServer = in.readLine()
- }
- in.close ; out.close ; socket.close
+ val socket =
+ if (serverAdr == "") compileSocket.getOrCreateSocket(vmArgs, !shutdown)
+ else Some(compileSocket.getSocket(serverAdr))
+
+ val sawerror: Boolean = socket match {
+ case None =>
+ val msg = if (shutdown) "[No compilation server running.]" else "Compilation failed."
+ Console println msg
+ !shutdown
+
+ case Some(sock) =>
+ var wasError = false
+
+ sock.applyReaderAndWriter { (in, out) =>
+ out println compileSocket.getPassword(sock.getPort())
+ out println args.mkString("\0")
+ def loop: Unit = in.readLine() match {
+ case null => ()
+ case fromServer =>
+ if (compileSocket.errorPattern matcher fromServer matches)
+ wasError = true
+
+ Console println fromServer
+ loop
+ }
+ }
+ wasError
}
if (sawerror) 1 else 0
}