summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/CompileServer.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-01 08:27:18 +0000
committerPaul Phillips <paulp@improving.org>2011-02-01 08:27:18 +0000
commitee4e09235afa578a7a33267061179ca338e396c0 (patch)
tree52ff21a786e84f0a3c47ef5666746591301cc47c /src/compiler/scala/tools/nsc/CompileServer.scala
parentd59d7f928d8a71d73d198690ab5816af3be90d6b (diff)
downloadscala-ee4e09235afa578a7a33267061179ca338e396c0.tar.gz
scala-ee4e09235afa578a7a33267061179ca338e396c0.tar.bz2
scala-ee4e09235afa578a7a33267061179ca338e396c0.zip
Eliminating duplication and trying to outrun ob...
Eliminating duplication and trying to outrun obsolescence in the exciting world of fsc. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/CompileServer.scala')
-rw-r--r--src/compiler/scala/tools/nsc/CompileServer.scala47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala
index 8998b8065e..5296432519 100644
--- a/src/compiler/scala/tools/nsc/CompileServer.scala
+++ b/src/compiler/scala/tools/nsc/CompileServer.scala
@@ -21,7 +21,7 @@ import scala.tools.util.SocketServer
* @version 1.0
*/
class StandardCompileServer extends SocketServer {
- def compileSocket: CompileSocket = CompileSocket // todo: make this a lazy val
+ lazy val compileSocket: CompileSocket = CompileSocket
val versionMsg = "Fast Scala compiler " +
Properties.versionString + " -- " +
@@ -75,27 +75,25 @@ class StandardCompileServer extends SocketServer {
val guessedPassword = in.readLine()
val input = in.readLine()
+ def fscError(msg: String): Unit = out println (
+ FakePos("fsc"),
+ msg + "\n fsc -help gives more information"
+ )
if (input == null || password != guessedPassword)
return
val args = input.split("\0", -1).toList
- if (args contains "-shutdown") {
- out.println("[Compile server exited]")
+ val command = newOfflineCompilerCommand(args, new Settings(fscError))
+
+ if (command.fscShutdown.value) {
shutDown = true
- return
+ return out.println("[Compile server exited]")
}
- if (args contains "-reset") {
- out.println("[Compile server was reset]")
+ if (command.fscReset.value) {
compiler = null
- return
+ return out.println("[Compile server was reset]")
}
- def fscError(msg: String) {
- out.println(FakePos("fsc"), msg + "\n fsc -help gives more information")
- }
-
- val command = newOfflineCompilerCommand(args, new Settings(fscError))
-
reporter = new ConsoleReporter(command.settings, in, out) {
// disable prompts, so that compile server cannot block
override def displayPrompt = ()
@@ -112,7 +110,7 @@ class StandardCompileServer extends SocketServer {
compiler.reporter = reporter
}
else {
- if (args contains "-verbose") {
+ if (command.verbose) {
val reason = if (compiler == null) "compiler is null" else "settings not equal"
out.println("[Starting new compile server instance because %s]".format(reason))
}
@@ -124,14 +122,15 @@ class StandardCompileServer extends SocketServer {
}
catch {
case ex @ FatalError(msg) =>
- if (command.settings.debug.value)
- ex.printStackTrace(out);
- reporter.error(null, "fatal error: " + msg)
- compiler = null
+ if (command.debug)
+ ex.printStackTrace(out)
+
+ reporter.error(null, "fatal error: " + msg)
+ compiler = null
case ex: Throwable =>
ex.printStackTrace(out);
- reporter.error(null, "fatal error (server aborted): " + ex.getMessage())
- shutDown = true
+ reporter.error(null, "fatal error (server aborted): " + ex.getMessage())
+ shutDown = true
}
}
@@ -139,7 +138,10 @@ class StandardCompileServer extends SocketServer {
if (isMemoryFullEnough)
compiler = null
}
+}
+
+object CompileServer extends StandardCompileServer {
/** A directory holding redirected output */
private val redirectDir = (compileSocket.tmpDir / "output-redirects").createDirectory()
@@ -151,12 +153,11 @@ class StandardCompileServer extends SocketServer {
redirect(System.setErr, "scala-compile-server-err.log")
System.err.println("...starting server on socket "+port+"...")
System.err.flush()
+
compileSocket.setPort(port)
run()
+
compileSocket.deletePort(port)
exit(0)
}
}
-
-
-object CompileServer extends StandardCompileServer