summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-01-25 09:09:51 -0800
committerPaul Phillips <paulp@improving.org>2013-01-25 09:09:51 -0800
commit0e6015d46df35a57c5acaf4fea2b0555ddd9b18e (patch)
tree534b28161f7195b56adaecffe4199bdd4ee2d708 /src
parentdacab70646561159b4c34c2d751e03b61eeee369 (diff)
parent1dab5bf91361b8d6073db05ba1dff1bc01a83220 (diff)
downloadscala-0e6015d46df35a57c5acaf4fea2b0555ddd9b18e.tar.gz
scala-0e6015d46df35a57c5acaf4fea2b0555ddd9b18e.tar.bz2
scala-0e6015d46df35a57c5acaf4fea2b0555ddd9b18e.zip
Merge pull request #1951 from JamesIry/SI-6987_2.10.x
SI-6987 Fixes fsc compile server verbose output
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/CompileServer.scala44
-rw-r--r--src/compiler/scala/tools/util/SocketServer.scala4
2 files changed, 31 insertions, 17 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala
index c23c1e6154..7a0a072bb8 100644
--- a/src/compiler/scala/tools/nsc/CompileServer.scala
+++ b/src/compiler/scala/tools/nsc/CompileServer.scala
@@ -92,10 +92,11 @@ class StandardCompileServer extends SocketServer {
val args = input.split("\0", -1).toList
val newSettings = new FscSettings(fscError)
- this.verbose = newSettings.verbose.value
val command = newOfflineCompilerCommand(args, newSettings)
+ this.verbose = newSettings.verbose.value
info("Settings after normalizing paths: " + newSettings)
+ if (!command.files.isEmpty) info("Input files after normalizing paths: " + (command.files mkString ","))
printMemoryStats()
// Update the idle timeout if given
@@ -173,11 +174,22 @@ object CompileServer extends StandardCompileServer {
/** A directory holding redirected output */
private lazy val redirectDir = (compileSocket.tmpDir / "output-redirects").createDirectory()
- private def redirect(setter: PrintStream => Unit, filename: String) {
- setter(new PrintStream((redirectDir / filename).createFile().bufferedOutput()))
- }
-
- def main(args: Array[String]) {
+ private def createRedirect(filename: String) =
+ new PrintStream((redirectDir / filename).createFile().bufferedOutput())
+
+ def main(args: Array[String]) =
+ execute(() => (), args)
+
+ /**
+ * Used for internal testing. The callback is called upon
+ * server start, notifying the caller that the server is
+ * ready to run. WARNING: the callback runs in the
+ * server's thread, blocking the server from doing any work
+ * until the callback is finished. Callbacks should be kept
+ * simple and clients should not try to interact with the
+ * server while the callback is processing.
+ */
+ def execute(startupCallback : () => Unit, args: Array[String]) {
val debug = args contains "-v"
if (debug) {
@@ -185,14 +197,16 @@ object CompileServer extends StandardCompileServer {
echo("Redirect dir is " + redirectDir)
}
- redirect(System.setOut, "scala-compile-server-out.log")
- 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
- sys exit 0
+ Console.withErr(createRedirect("scala-compile-server-err.log")) {
+ Console.withOut(createRedirect("scala-compile-server-out.log")) {
+ Console.err.println("...starting server on socket "+port+"...")
+ Console.err.flush()
+ compileSocket setPort port
+ startupCallback()
+ run()
+
+ compileSocket deletePort port
+ }
+ }
}
}
diff --git a/src/compiler/scala/tools/util/SocketServer.scala b/src/compiler/scala/tools/util/SocketServer.scala
index d29a370c28..1b06ce2ff2 100644
--- a/src/compiler/scala/tools/util/SocketServer.scala
+++ b/src/compiler/scala/tools/util/SocketServer.scala
@@ -16,8 +16,8 @@ trait CompileOutputCommon {
def verbose: Boolean
def info(msg: String) = if (verbose) echo(msg)
- def echo(msg: String) = Console println msg
- def warn(msg: String) = System.err println msg
+ def echo(msg: String) = {Console println msg; Console.flush}
+ def warn(msg: String) = {Console.err println msg; Console.flush}
def fatal(msg: String) = { warn(msg) ; sys.exit(1) }
}