summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/CompileSocket.scala
diff options
context:
space:
mode:
authorLex Spoon <lex@lexspoon.org>2006-07-14 17:04:10 +0000
committerLex Spoon <lex@lexspoon.org>2006-07-14 17:04:10 +0000
commit78f9cc60cf472c03ccf23c9ca1ecef269e646bce (patch)
tree50025351798394b2ec9f2cbdee31a6e3724787e3 /src/compiler/scala/tools/nsc/CompileSocket.scala
parent5c25a0511871c1e9da4188d67446f360c65b896c (diff)
downloadscala-78f9cc60cf472c03ccf23c9ca1ecef269e646bce.tar.gz
scala-78f9cc60cf472c03ccf23c9ca1ecef269e646bce.tar.bz2
scala-78f9cc60cf472c03ccf23c9ca1ecef269e646bce.zip
try exec-ing "scala.bat" if "scala" by itself d...
try exec-ing "scala.bat" if "scala" by itself does not work
Diffstat (limited to 'src/compiler/scala/tools/nsc/CompileSocket.scala')
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala
index f0d30ef6f3..193aad072d 100644
--- a/src/compiler/scala/tools/nsc/CompileSocket.scala
+++ b/src/compiler/scala/tools/nsc/CompileSocket.scala
@@ -98,11 +98,36 @@ object CompileSocket {
/** Time (in ms) to sleep between two polls */
private val sleepTime = 20
- /** The command which starts the compile server, given vm arguments
- * @param vmArgs the argument string to be passed to the java or scala command
- * the string must be either empty or start with a ' '.
- */
- def serverCommand(vmArgs: String): String = vmCommand+vmArgs+" "+serverClass
+ /** The command which starts the compile server, given vm arguments.
+ * Multiple responses are given because different commands are needed
+ * on different platforms; each possibility should be tried in order.
+ *
+ * @param vmArgs the argument string to be passed to the java or scala command
+ * the string must be either empty or start with a ' '.
+ */
+ def serverCommands(vmArgs: String): List[String] =
+ List(
+ vmCommand+vmArgs+" "+serverClass,
+ vmCommand+".bat"+vmArgs+" "+serverClass)
+
+ /** Start a new server; returns true iff it succeeds */
+ def startNewServer(vmArgs: String): Boolean = {
+ for(val cmd <- serverCommands(vmArgs)) {
+ try {
+Console.println("trying: " + cmd + "...\n")
+ Runtime.getRuntime().exec(cmd)
+ Console.println("succeeded")
+ return true
+ } catch {
+ case e:IOException => {
+ Console.println(e)
+ ()
+ }
+ }
+ }
+ return false
+ }
+
/** The port identification file */
def portFile(port: int) = new File(tmpDir, port.toString())
@@ -124,6 +149,7 @@ object CompileSocket {
}
}
+
/** Get the port number to which a scala compile server is connected;
* If no server is running yet, create one
*/
@@ -131,7 +157,12 @@ object CompileSocket {
var attempts = 0;
var port = pollPort()
if (port < 0) {
- Runtime.getRuntime().exec(serverCommand(vmArgs))
+ if(!startNewServer(vmArgs)) {
+ System.err.println("cannot start server. tried commands:")
+ for(val cmd <- serverCommands(vmArgs))
+ System.err.println(cmd)
+ exit(1)
+ }
}
while (port < 0 && attempts < MaxAttempts) {
attempts = attempts + 1
@@ -139,8 +170,7 @@ object CompileSocket {
port = pollPort()
}
if (port < 0) {
- System.err.println("cannot start server with command")
- System.err.println(serverCommand(vmArgs))
+ Console.println("Could not connect to server.")
exit(1)
}
port