summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/CompileServer.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/CompileServer.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/CompileServer.scala')
-rw-r--r--src/compiler/scala/tools/nsc/CompileServer.scala48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala
index a34be6226b..866975b414 100644
--- a/src/compiler/scala/tools/nsc/CompileServer.scala
+++ b/src/compiler/scala/tools/nsc/CompileServer.scala
@@ -21,7 +21,9 @@ import settings.FscSettings
*/
class StandardCompileServer extends SocketServer {
lazy val compileSocket: CompileSocket = CompileSocket
+
private var compiler: Global = null
+ private def clearCompiler() = compiler = null
var reporter: ConsoleReporter = _
var shutdown = false
@@ -58,7 +60,7 @@ class StandardCompileServer extends SocketServer {
(totalMemory - freeMemory).toDouble / maxMemory.toDouble > MaxCharge
}
- protected def newOfflineCompilerCommand(arguments: List[String], settings: Settings) =
+ protected def newOfflineCompilerCommand(arguments: List[String], settings: FscSettings): OfflineCompilerCommand =
new OfflineCompilerCommand(arguments, settings)
/** Problematically, Settings are only considered equal if every setting
@@ -69,7 +71,7 @@ class StandardCompileServer extends SocketServer {
* and which do not interestingly influence compilation products.
*/
def unequalSettings(s1: Settings, s2: Settings): Set[Settings#Setting] = {
- val ignoreSettings = Set("-d", "-encoding", "-verbose")
+ val ignoreSettings = Set("-d", "-encoding", "-currentDir")
def trim (s: Settings): Set[Settings#Setting] = (
s.userSetSettings.toSet[Settings#Setting] filterNot (ss => ignoreSettings exists (ss respondsTo _))
)
@@ -80,7 +82,6 @@ class StandardCompileServer extends SocketServer {
}
def session() {
- printMemoryStats()
val password = compileSocket getPassword port
val guessedPassword = in.readLine()
val input = in.readLine()
@@ -92,29 +93,34 @@ class StandardCompileServer extends SocketServer {
if (input == null || password != guessedPassword)
return
- val args = input.split("\0", -1).toList
- val settings = new FscSettings(fscError)
- val command = newOfflineCompilerCommand(args, settings)
+ val args = input.split("\0", -1).toList
+ val newSettings = new FscSettings(fscError)
+ this.verbose = newSettings.verbose.value
+ val command = newOfflineCompilerCommand(args, newSettings)
+
+ info("Settings after normalizing paths: " + newSettings)
+ printMemoryStats()
// Update the idle timeout if given
- if (!settings.idleMins.isDefault) {
- val mins = settings.idleMins.value
+ if (!newSettings.idleMins.isDefault) {
+ val mins = newSettings.idleMins.value
if (mins == 0) echo("Disabling idle timeout on compile server.")
else echo("Setting idle timeout to " + mins + " minutes.")
this.idleMinutes = mins
}
- if (settings.shutdown.value) {
+ if (newSettings.shutdown.value) {
shutdown = true
return out.println("[Compile server exited]")
}
- if (settings.reset.value) {
- compiler = null
- return out.println("[Compile server was reset]")
+ if (newSettings.reset.value) {
+ clearCompiler()
+ out.println("[Compile server was reset]")
+ if (command.files.isEmpty)
+ return
}
- this.verbose = settings.verbose.value
- reporter = new ConsoleReporter(command.settings, in, out) {
+ reporter = new ConsoleReporter(newSettings, in, out) {
// disable prompts, so that compile server cannot block
override def displayPrompt = ()
}
@@ -124,7 +130,7 @@ class StandardCompileServer extends SocketServer {
info("[Compiler version: " + Properties.versionString + ".]")
return false
}
- val unequal = unequalSettings(command.settings, compiler.settings)
+ val unequal = unequalSettings(newSettings, compiler.settings)
if (unequal.nonEmpty) {
info("[Replacing compiler with new instance because settings are unequal.]")
info("[Asymmetric settings: " + unequal.mkString(", ") + "]")
@@ -133,24 +139,26 @@ class StandardCompileServer extends SocketServer {
}
if (command.shouldStopWithInfo)
- reporter.info(null, command.getInfoMessage(newGlobal(command.settings, reporter)), true)
+ reporter.info(null, command.getInfoMessage(newGlobal(newSettings, reporter)), true)
else if (command.files.isEmpty)
reporter.info(null, command.usageMsg, true)
else {
if (isCompilerReusable) {
- compiler.settings = command.settings
+ info("[Reusing existing Global instance.]")
+ compiler.settings = newSettings
compiler.reporter = reporter
}
else {
- compiler = newGlobal(command.settings, reporter)
+ compiler = newGlobal(newSettings, reporter)
}
val c = compiler
try new c.Run() compile command.files
catch {
case ex @ FatalError(msg) =>
reporter.error(null, "fatal error: " + msg)
- compiler = null
+ clearCompiler()
case ex =>
+ warn("Compile server encountered fatal condition: " + ex)
shutdown = true
throw ex
}
@@ -158,7 +166,7 @@ class StandardCompileServer extends SocketServer {
reporter.printSummary()
if (isMemoryFullEnough) {
info("Nulling out compiler due to memory utilization.")
- compiler = null
+ clearCompiler()
}
}
}