summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-01-29 16:53:19 +0000
committermichelou <michelou@epfl.ch>2007-01-29 16:53:19 +0000
commitfba3480e739e2fe318fa9dcb71da424fb90d06fd (patch)
treee5639c31570122ab0e708be84c701306f795c31b /src/compiler/scala/tools
parent0e147167565d625c7713a6e74c3d58d0ace24439 (diff)
downloadscala-fba3480e739e2fe318fa9dcb71da424fb90d06fd.tar.gz
scala-fba3480e739e2fe318fa9dcb71da424fb90d06fd.tar.bz2
scala-fba3480e739e2fe318fa9dcb71da424fb90d06fd.zip
moved version/copyright properties from source ...
moved version/copyright properties from source code to property file
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r--src/compiler/scala/tools/ant/Scalac.scala5
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-unix.tmpl2
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-windows.tmpl6
-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
10 files changed, 89 insertions, 63 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala
index e345db7ddc..61afdeb081 100644
--- a/src/compiler/scala/tools/ant/Scalac.scala
+++ b/src/compiler/scala/tools/ant/Scalac.scala
@@ -9,8 +9,6 @@
package scala.tools.ant
-import java.lang.System.getProperty
-
import java.io.File
import java.net.{URL, URLClassLoader}
import java.util.{ArrayList, Vector}
@@ -71,9 +69,6 @@ import scala.tools.nsc.{Global, FatalError, Settings}
*/
class Scalac extends MatchingTask {
- private val SCALA_PRODUCT: String = getProperty("scala.product", "scalac")
- private val SCALA_VERSION: String = getProperty("scala.version", "Unknown version")
-
/** The unique Ant file utilities instance to use in this task. */
private val fileUtils = FileUtils.newFileUtils()
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
index 3e38b89705..8c7dbbd5c6 100644
--- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -70,4 +70,4 @@ if $cygwin; then
BOOT_CLASSPATH=`cygpath --path --$format "$BOOT_CLASSPATH"`
fi
-${JAVACMD:=java} @javaflags@ -Xbootclasspath/a:"$BOOT_CLASSPATH" -cp "$EXTENSION_CLASSPATH" -Dscala.home="$SCALA_HOME" -Denv.classpath="$CLASSPATH" -Dscala.tool.name="@name@" -Dscala.tool.version="@version@" @properties@ @class@ @toolflags@ "$@@"
+${JAVACMD:=java} @javaflags@ -Xbootclasspath/a:"$BOOT_CLASSPATH" -cp "$EXTENSION_CLASSPATH" -Dscala.home="$SCALA_HOME" -Denv.classpath="$CLASSPATH" @properties@ @class@ @toolflags@ "$@@"
diff --git a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl
index 56e582b5ea..11b9a3ae3c 100644
--- a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl
@@ -55,16 +55,12 @@ shift
goto loop
:exec
-set _PROPS=-Dscala.home="%_SCALA_HOME%" -Denv.classpath="%CLASSPATH%" -Dscala.tool.name="@name@" -Dscala.tool.version="@version@" @properties@
+set _PROPS=-Dscala.home="%_SCALA_HOME%" -Denv.classpath="%CLASSPATH%" @properties@
rem echo %_JAVACMD% -Xbootclasspath/a:"%_BOOT_CLASSPATH%" @javaflags@ %_PROPS% -cp "%_EXTENSION_CLASSPATH%" @class@ @toolflags@ %_ARGS%
%_JAVACMD% -Xbootclasspath/a:"%_BOOT_CLASSPATH%" @javaflags@ %_PROPS% -cp "%_EXTENSION_CLASSPATH%" @class@ @toolflags@ %_ARGS%
goto end
-:version
-echo @name@ version @version@ -- @copyright@
-goto end
-
rem ##########################################################################
rem # subroutines
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