summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc')
-rw-r--r--src/compiler/scala/tools/nsc/CompileClient.scala11
-rw-r--r--src/compiler/scala/tools/nsc/CompileServer.scala30
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala17
-rw-r--r--src/compiler/scala/tools/nsc/Main.scala16
-rw-r--r--src/compiler/scala/tools/nsc/MainGenericRunner.scala13
-rw-r--r--src/compiler/scala/tools/nsc/Properties.scala48
-rw-r--r--src/compiler/scala/tools/nsc/Settings.scala4
7 files changed, 87 insertions, 52 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala
index e8496dc1ec..bb24ad2d30 100644
--- a/src/compiler/scala/tools/nsc/CompileClient.scala
+++ b/src/compiler/scala/tools/nsc/CompileClient.scala
@@ -1,12 +1,11 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2006 LAMP/EPFL
+ * Copyright 2005-2007 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
package scala.tools.nsc
-import java.lang.System.getProperty
import java.io.{BufferedReader, File, InputStreamReader, PrintWriter}
import scala.compat.StringBuilder
@@ -16,11 +15,9 @@ import scala.tools.util.StringOps
* language Scala.
*/
object CompileClient {
- val PRODUCT: String = getProperty("scala.tool.name", "scalac")
- val VERSION: String = getProperty("scala.tool.version", "unknown version")
- val COPYRIGHT: String = getProperty("scala.copyright", "(c) 2002-2007 LAMP/EPFL")
-
- val versionMsg = PRODUCT + " " + VERSION + " -- " + COPYRIGHT
+ val versionMsg = "Fast Scala Compiler " +
+ Properties.versionString + " -- " +
+ Properties.copyrightString
var verbose = false
var version = false
diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala
index e2d2dfb5ab..bc99bf321f 100644
--- a/src/compiler/scala/tools/nsc/CompileServer.scala
+++ b/src/compiler/scala/tools/nsc/CompileServer.scala
@@ -6,16 +6,14 @@
package scala.tools.nsc
-import scala.tools.util.SocketServer
-import scala.tools.nsc.util.FakePos //Position
-import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
-import scala.tools.nsc.doc.DocGenerator
+import java.io.{BufferedOutputStream, File, FileOutputStream, PrintStream}
+import java.lang.{Runtime, System, Thread}
+
import scala.concurrent.Process.spawn
-import java.lang.System
-import java.lang.Thread
-import java.lang.Runtime
-import java.io.File
-import java.io.{PrintStream, BufferedOutputStream, FileOutputStream}
+import scala.tools.nsc.doc.DocGenerator
+import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
+import scala.tools.nsc.util.FakePos //Position
+import scala.tools.util.SocketServer
/** The main class for NSC, a compiler for the programming
* language Scala.
@@ -25,13 +23,9 @@ import java.io.{PrintStream, BufferedOutputStream, FileOutputStream}
*/
object CompileServer extends SocketServer {
- val PRODUCT: String =
- System.getProperty("scala.tool.name", "scalac")
- val VERSION: String =
- System.getProperty("scala.tool.version", "unknown version")
- val COPYRIGHT: String =
- System.getProperty("scala.copyright", "(c) 2002-2007 LAMP/EPFL")
- val versionMsg = PRODUCT + " " + VERSION + " -- " + COPYRIGHT
+ val versionMsg = "Fast Scala compiler " +
+ Properties.versionString + " -- " +
+ Properties.copyrightString
val MaxCharge = 0.8
@@ -99,8 +93,8 @@ object CompileServer extends SocketServer {
override def displayPrompt = {}
}
def error(msg: String): unit =
- reporter.error(/*new Position*/ FakePos(PRODUCT),
- msg + "\n " + PRODUCT + " -help gives more information")
+ reporter.error(/*new Position*/ FakePos("fsc"),
+ msg + "\n fsc -help gives more information")
val command = new CompilerCommand(args, error, false) {
override val cmdName = "fsc"
settings.disable(settings.prompt)
diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala
index ea953e1dd5..0fa020d4d3 100644
--- a/src/compiler/scala/tools/nsc/CompileSocket.scala
+++ b/src/compiler/scala/tools/nsc/CompileSocket.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2006 LAMP/EPFL
+ * Copyright 2005-2007 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -10,6 +10,7 @@ import java.lang.{Thread, System, Runtime}
import java.lang.NumberFormatException
import java.io.{File, IOException, PrintWriter, FileOutputStream}
import java.io.{BufferedReader, FileReader}
+import java.util.regex.Pattern
import java.net._
object CompileSocket {
@@ -19,19 +20,17 @@ object CompileSocket {
*/
private val dirName = "scalac-compile-server-port"
- private val isWin = System.getProperty("os.name") startsWith "Windows"
- private val cmdName = if (isWin) "scala.bat" else "scala"
-
/** The vm-part of the command to start a new scala compile server */
private val vmCommand =
- System.getProperty("scala.home") match {
- case null => cmdName
+ Properties.scalaHome match {
+ case null =>
+ Properties.cmdName
case dirname =>
- val trial = new File(new File(dirname, "bin"), cmdName)
+ val trial = new File(new File(dirname, "bin"), Properties.cmdName)
if (trial.canRead)
trial.getPath
else
- cmdName
+ Properties.cmdName
}
/** The class name of the scala compile server */
@@ -41,7 +40,7 @@ object CompileSocket {
val errorRegex = ".*errors? found.*"
/** A Pattern object for checking compiler output for errors */
- val errorPattern = java.util.regex.Pattern.compile(errorRegex)
+ val errorPattern = Pattern.compile(errorRegex)
private def error(msg: String) = System.err.println(msg)
diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala
index 0ff21f99b8..81b0696a3b 100644
--- a/src/compiler/scala/tools/nsc/Main.scala
+++ b/src/compiler/scala/tools/nsc/Main.scala
@@ -6,10 +6,9 @@
package scala.tools.nsc
-import java.lang.System.getProperty
-import scala.tools.nsc.util.FakePos //{Position}
-import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
import scala.tools.nsc.doc.DocGenerator
+import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
+import scala.tools.nsc.util.FakePos //{Position}
/** The main class for NSC, a compiler for the programming
@@ -17,17 +16,16 @@ import scala.tools.nsc.doc.DocGenerator
*/
object Main extends AnyRef with EvalLoop {
- val PRODUCT: String = getProperty("scala.tool.name", "scalac")
- val VERSION: String = getProperty("scala.tool.version", "unknown version")
- val COPYRIGHT: String = getProperty("scala.copyright", "(c) 2002-2007 LAMP/EPFL")
- val versionMsg = PRODUCT + " " + VERSION + " -- " + COPYRIGHT
+ val versionMsg = "Scala compiler " +
+ Properties.versionString + " -- " +
+ Properties.copyrightString
val prompt = "\nnsc> "
var reporter: ConsoleReporter = _
def error(msg: String): unit =
- reporter.error(/*new Position */FakePos(PRODUCT),
- msg + "\n " + PRODUCT + " -help gives more information")
+ reporter.error(/*new Position */FakePos("scalac"),
+ msg + "\n scalac -help gives more information")
/* needed ?? */
def errors() = reporter.errors
diff --git a/src/compiler/scala/tools/nsc/MainGenericRunner.scala b/src/compiler/scala/tools/nsc/MainGenericRunner.scala
index 9d17154eae..d0ecc50417 100644
--- a/src/compiler/scala/tools/nsc/MainGenericRunner.scala
+++ b/src/compiler/scala/tools/nsc/MainGenericRunner.scala
@@ -7,9 +7,8 @@
package scala.tools.nsc
-import java.lang.System.getProperty
-import java.lang.{ClassNotFoundException, NoSuchMethodException}
import java.io.File
+import java.lang.{ClassNotFoundException, NoSuchMethodException}
import java.lang.reflect.InvocationTargetException
/** An object that runs Scala code. It has three possible
@@ -24,8 +23,8 @@ object MainGenericRunner {
* @param classpath
* @return ...
*/
- def addClasspathExtras(classpath: String): String = {
- val scalaHome = getProperty("scala.home")
+ private def addClasspathExtras(classpath: String): String = {
+ val scalaHome = Properties.scalaHome
val extraClassPath =
if (scalaHome eq null)
@@ -70,10 +69,10 @@ object MainGenericRunner {
}
if (settings.version.value) {
- val version = getProperty("scala.tool.version", "unknown version")
Console.println(
- "Scala code runner version " + version + " -- " +
- "(c) 2002-2007 LAMP/EPFL")
+ "Scala code runner " +
+ Properties.versionString + " -- " +
+ Properties.copyrightString)
return
}
diff --git a/src/compiler/scala/tools/nsc/Properties.scala b/src/compiler/scala/tools/nsc/Properties.scala
new file mode 100644
index 0000000000..ea13f14a81
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/Properties.scala
@@ -0,0 +1,48 @@
+/* NSC -- new Scala compiler
+ * Copyright 2006-2007 LAMP/EPFL
+ * @author Stephane Micheloud
+ */
+
+// $Id: $
+
+package scala.tools.nsc
+
+/** A utility to load the compiler properties from a Java properties file
+ * included in the jar.
+ */
+object Properties {
+
+ /** The name of the properties file */
+ private val propFilename = "/compiler.properties"
+
+ /** The loaded properties */
+ private val props = {
+ val props = new java.util.Properties
+ val stream = classOf[Global].getResourceAsStream(propFilename)
+ if (stream != null)
+ props.load(stream)
+ props
+ }
+
+ /** The version number of the jar this was loaded from, or
+ * "(unknown)" if it cannot be determined.
+ */
+ val versionString: String = {
+ val defaultString = "(unknown)"
+ "version " + props.getProperty("version.number")
+ }
+
+ val copyrightString: String = {
+ val defaultString = "(c) 2002-2006 LAMP/EPFL"
+ props.getProperty("copyright.string", defaultString)
+ }
+
+ val scalaHome: String =
+ System.getProperty("scala.home")
+
+ val cmdName: String = {
+ val isWin = System.getProperty("os.name") startsWith "Windows"
+ if (isWin) "scala.bat" else "scala"
+ }
+
+}
diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala
index bde12d3be0..8013b219b7 100644
--- a/src/compiler/scala/tools/nsc/Settings.scala
+++ b/src/compiler/scala/tools/nsc/Settings.scala
@@ -49,7 +49,7 @@ class Settings(error: String => unit) {
else p2
private def guessedScalaBootClassPath = {
- val scalaHome = System.getProperty("scala.home")
+ val scalaHome = Properties.scalaHome
if (scalaHome ne null) {
val guessJar = new File(new File(new File(scalaHome), "lib"), "scala-library.jar")
if (guessJar.exists()) guessJar.getPath()
@@ -61,7 +61,7 @@ class Settings(error: String => unit) {
}
private def guessedScalaExtDirs = {
- val scalaHome = System.getProperty("scala.home")
+ val scalaHome = Properties.scalaHome
if (scalaHome ne null) {
val guess = new File(new File(scalaHome), "lib")
if (guess.exists()) guess.getPath else null