moved version/copyright properties from source code to property file

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@9792 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
michelou 2007-01-29 16:53:19 +00:00
parent 00fcc70845
commit 836e29f567
11 changed files with 122 additions and 64 deletions

View File

@ -29,7 +29,7 @@ PROPERTIES
<property file="${properties.file}"/> <property file="${properties.file}"/>
<!-- Defines the product being built --> <!-- Defines the product being built -->
<property name="vendor.name" value="LAMP/EPFL"/> <property name="vendor.name" value="LAMP/EPFL"/>
<property name="copyright.string" value="Copyright 2002-2007 ${vendor.name}"/> <property name="copyright.string" value="(c) 2002-2007 ${vendor.name}"/>
<property name="number.file" value="${basedir}/build.number"/> <property name="number.file" value="${basedir}/build.number"/>
<!-- Configuring how the compiler is run --> <!-- Configuring how the compiler is run -->
<property name="nsc.log-files" value="no"/> <property name="nsc.log-files" value="no"/>
@ -64,6 +64,7 @@ PROPERTIES
<property name="scalac.exec.name" value="scalac"/> <property name="scalac.exec.name" value="scalac"/>
<property name="scaladoc.exec.name" value="scaladoc"/> <property name="scaladoc.exec.name" value="scaladoc"/>
<property name="fsc.exec.name" value="fsc"/> <property name="fsc.exec.name" value="fsc"/>
<property name="comp.prop.name" value="compiler.properties"/>
<!-- =========================================================================== <!-- ===========================================================================
INITIALISATION INITIALISATION
@ -317,6 +318,16 @@ BUILD LOCAL REFERENCE (LOCKER) LAYER
<include name="**/*.scala"/> <include name="**/*.scala"/>
<excludesfile name="${nsc.excludes.file}" if="excludes.avail"/> <excludesfile name="${nsc.excludes.file}" if="excludes.avail"/>
</starr> </starr>
<echo
file="${locker.dir}/lib/compiler/${comp.prop.name}"
message="version.number=${version.number}${line.separator}"
append="false"
/>
<echo
file="${locker.dir}/lib/compiler/${comp.prop.name}"
message="copyright.string=${copyright.string}${line.separator}"
append="true"
/>
<!-- Timing the build --> <!-- Timing the build -->
<stopwatch name="timer.locker" action="total"/> <stopwatch name="timer.locker" action="total"/>
<!-- Copy support files to build folder and links external libraries--> <!-- Copy support files to build folder and links external libraries-->
@ -451,6 +462,16 @@ BUILD QUICK-TEST LAYER
<include name="**/*.scala"/> <include name="**/*.scala"/>
<excludesfile name="${nsc.excludes.file}" if="excludes.avail"/> <excludesfile name="${nsc.excludes.file}" if="excludes.avail"/>
</locker> </locker>
<echo
file="${quick.dir}/lib/compiler/${comp.prop.name}"
message="version.number=${version.number}${line.separator}"
append="false"
/>
<echo
file="${quick.dir}/lib/compiler/${comp.prop.name}"
message="copyright.string=${copyright.string}${line.separator}"
append="true"
/>
<!-- Timing the build --> <!-- Timing the build -->
<stopwatch name="timer.quick" action="total"/> <stopwatch name="timer.quick" action="total"/>
<!-- Copy support files to build folder and links external libraries--> <!-- Copy support files to build folder and links external libraries-->
@ -585,6 +606,17 @@ TEST
<include name="**/*.scala"/> <include name="**/*.scala"/>
<excludesfile name="${nsc.excludes.file}" if="excludes.avail"/> <excludesfile name="${nsc.excludes.file}" if="excludes.avail"/>
</quick> </quick>
<echo
file="${strap.dir}/lib/compiler/${comp.prop.name}"
message="version.number=${version.number}${line.separator}"
append="false"
/>
<echo
file="${strap.dir}/lib/compiler/${comp.prop.name}"
message="copyright.string=${copyright.string}${line.separator}"
append="true"
/>
<!-- Timing the build --> <!-- Timing the build -->
<stopwatch name="timer.strap" action="total"/> <stopwatch name="timer.strap" action="total"/>
<!-- Copy support files to build folder and links external libraries--> <!-- Copy support files to build folder and links external libraries-->

View File

@ -9,8 +9,6 @@
package scala.tools.ant package scala.tools.ant
import java.lang.System.getProperty
import java.io.File import java.io.File
import java.net.{URL, URLClassLoader} import java.net.{URL, URLClassLoader}
import java.util.{ArrayList, Vector} import java.util.{ArrayList, Vector}
@ -71,9 +69,6 @@ import scala.tools.nsc.{Global, FatalError, Settings}
*/ */
class Scalac extends MatchingTask { 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. */ /** The unique Ant file utilities instance to use in this task. */
private val fileUtils = FileUtils.newFileUtils() private val fileUtils = FileUtils.newFileUtils()

View File

@ -70,4 +70,4 @@ if $cygwin; then
BOOT_CLASSPATH=`cygpath --path --$format "$BOOT_CLASSPATH"` BOOT_CLASSPATH=`cygpath --path --$format "$BOOT_CLASSPATH"`
fi 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@ "$@@"

View File

@ -55,16 +55,12 @@ shift
goto loop goto loop
:exec :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% 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% %_JAVACMD% -Xbootclasspath/a:"%_BOOT_CLASSPATH%" @javaflags@ %_PROPS% -cp "%_EXTENSION_CLASSPATH%" @class@ @toolflags@ %_ARGS%
goto end goto end
:version
echo @name@ version @version@ -- @copyright@
goto end
rem ########################################################################## rem ##########################################################################
rem # subroutines rem # subroutines

View File

@ -1,12 +1,11 @@
/* NSC -- new Scala compiler /* NSC -- new Scala compiler
* Copyright 2005-2006 LAMP/EPFL * Copyright 2005-2007 LAMP/EPFL
* @author Martin Odersky * @author Martin Odersky
*/ */
// $Id$ // $Id$
package scala.tools.nsc package scala.tools.nsc
import java.lang.System.getProperty
import java.io.{BufferedReader, File, InputStreamReader, PrintWriter} import java.io.{BufferedReader, File, InputStreamReader, PrintWriter}
import scala.compat.StringBuilder import scala.compat.StringBuilder
@ -16,11 +15,9 @@ import scala.tools.util.StringOps
* language Scala. * language Scala.
*/ */
object CompileClient { object CompileClient {
val PRODUCT: String = getProperty("scala.tool.name", "scalac") val versionMsg = "Fast Scala Compiler " +
val VERSION: String = getProperty("scala.tool.version", "unknown version") Properties.versionString + " -- " +
val COPYRIGHT: String = getProperty("scala.copyright", "(c) 2002-2007 LAMP/EPFL") Properties.copyrightString
val versionMsg = PRODUCT + " " + VERSION + " -- " + COPYRIGHT
var verbose = false var verbose = false
var version = false var version = false

View File

@ -6,16 +6,14 @@
package scala.tools.nsc package scala.tools.nsc
import scala.tools.util.SocketServer import java.io.{BufferedOutputStream, File, FileOutputStream, PrintStream}
import scala.tools.nsc.util.FakePos //Position import java.lang.{Runtime, System, Thread}
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
import scala.tools.nsc.doc.DocGenerator
import scala.concurrent.Process.spawn import scala.concurrent.Process.spawn
import java.lang.System import scala.tools.nsc.doc.DocGenerator
import java.lang.Thread import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
import java.lang.Runtime import scala.tools.nsc.util.FakePos //Position
import java.io.File import scala.tools.util.SocketServer
import java.io.{PrintStream, BufferedOutputStream, FileOutputStream}
/** The main class for NSC, a compiler for the programming /** The main class for NSC, a compiler for the programming
* language Scala. * language Scala.
@ -25,13 +23,9 @@ import java.io.{PrintStream, BufferedOutputStream, FileOutputStream}
*/ */
object CompileServer extends SocketServer { object CompileServer extends SocketServer {
val PRODUCT: String = val versionMsg = "Fast Scala compiler " +
System.getProperty("scala.tool.name", "scalac") Properties.versionString + " -- " +
val VERSION: String = Properties.copyrightString
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 MaxCharge = 0.8 val MaxCharge = 0.8
@ -99,8 +93,8 @@ object CompileServer extends SocketServer {
override def displayPrompt = {} override def displayPrompt = {}
} }
def error(msg: String): unit = def error(msg: String): unit =
reporter.error(/*new Position*/ FakePos(PRODUCT), reporter.error(/*new Position*/ FakePos("fsc"),
msg + "\n " + PRODUCT + " -help gives more information") msg + "\n fsc -help gives more information")
val command = new CompilerCommand(args, error, false) { val command = new CompilerCommand(args, error, false) {
override val cmdName = "fsc" override val cmdName = "fsc"
settings.disable(settings.prompt) settings.disable(settings.prompt)

View File

@ -1,5 +1,5 @@
/* NSC -- new Scala compiler /* NSC -- new Scala compiler
* Copyright 2005-2006 LAMP/EPFL * Copyright 2005-2007 LAMP/EPFL
* @author Martin Odersky * @author Martin Odersky
*/ */
// $Id$ // $Id$
@ -10,6 +10,7 @@ import java.lang.{Thread, System, Runtime}
import java.lang.NumberFormatException import java.lang.NumberFormatException
import java.io.{File, IOException, PrintWriter, FileOutputStream} import java.io.{File, IOException, PrintWriter, FileOutputStream}
import java.io.{BufferedReader, FileReader} import java.io.{BufferedReader, FileReader}
import java.util.regex.Pattern
import java.net._ import java.net._
object CompileSocket { object CompileSocket {
@ -19,19 +20,17 @@ object CompileSocket {
*/ */
private val dirName = "scalac-compile-server-port" 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 */ /** The vm-part of the command to start a new scala compile server */
private val vmCommand = private val vmCommand =
System.getProperty("scala.home") match { Properties.scalaHome match {
case null => cmdName case null =>
Properties.cmdName
case dirname => case dirname =>
val trial = new File(new File(dirname, "bin"), cmdName) val trial = new File(new File(dirname, "bin"), Properties.cmdName)
if (trial.canRead) if (trial.canRead)
trial.getPath trial.getPath
else else
cmdName Properties.cmdName
} }
/** The class name of the scala compile server */ /** The class name of the scala compile server */
@ -41,7 +40,7 @@ object CompileSocket {
val errorRegex = ".*errors? found.*" val errorRegex = ".*errors? found.*"
/** A Pattern object for checking compiler output for errors */ /** 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) private def error(msg: String) = System.err.println(msg)

View File

@ -6,10 +6,9 @@
package scala.tools.nsc 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.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 /** 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 { object Main extends AnyRef with EvalLoop {
val PRODUCT: String = getProperty("scala.tool.name", "scalac") val versionMsg = "Scala compiler " +
val VERSION: String = getProperty("scala.tool.version", "unknown version") Properties.versionString + " -- " +
val COPYRIGHT: String = getProperty("scala.copyright", "(c) 2002-2007 LAMP/EPFL") Properties.copyrightString
val versionMsg = PRODUCT + " " + VERSION + " -- " + COPYRIGHT
val prompt = "\nnsc> " val prompt = "\nnsc> "
var reporter: ConsoleReporter = _ var reporter: ConsoleReporter = _
def error(msg: String): unit = def error(msg: String): unit =
reporter.error(/*new Position */FakePos(PRODUCT), reporter.error(/*new Position */FakePos("scalac"),
msg + "\n " + PRODUCT + " -help gives more information") msg + "\n scalac -help gives more information")
/* needed ?? */ /* needed ?? */
def errors() = reporter.errors def errors() = reporter.errors

View File

@ -7,9 +7,8 @@
package scala.tools.nsc package scala.tools.nsc
import java.lang.System.getProperty
import java.lang.{ClassNotFoundException, NoSuchMethodException}
import java.io.File import java.io.File
import java.lang.{ClassNotFoundException, NoSuchMethodException}
import java.lang.reflect.InvocationTargetException import java.lang.reflect.InvocationTargetException
/** An object that runs Scala code. It has three possible /** An object that runs Scala code. It has three possible
@ -24,8 +23,8 @@ object MainGenericRunner {
* @param classpath * @param classpath
* @return ... * @return ...
*/ */
def addClasspathExtras(classpath: String): String = { private def addClasspathExtras(classpath: String): String = {
val scalaHome = getProperty("scala.home") val scalaHome = Properties.scalaHome
val extraClassPath = val extraClassPath =
if (scalaHome eq null) if (scalaHome eq null)
@ -70,10 +69,10 @@ object MainGenericRunner {
} }
if (settings.version.value) { if (settings.version.value) {
val version = getProperty("scala.tool.version", "unknown version")
Console.println( Console.println(
"Scala code runner version " + version + " -- " + "Scala code runner " +
"(c) 2002-2007 LAMP/EPFL") Properties.versionString + " -- " +
Properties.copyrightString)
return return
} }

View File

@ -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"
}
}

View File

@ -49,7 +49,7 @@ class Settings(error: String => unit) {
else p2 else p2
private def guessedScalaBootClassPath = { private def guessedScalaBootClassPath = {
val scalaHome = System.getProperty("scala.home") val scalaHome = Properties.scalaHome
if (scalaHome ne null) { if (scalaHome ne null) {
val guessJar = new File(new File(new File(scalaHome), "lib"), "scala-library.jar") val guessJar = new File(new File(new File(scalaHome), "lib"), "scala-library.jar")
if (guessJar.exists()) guessJar.getPath() if (guessJar.exists()) guessJar.getPath()
@ -61,7 +61,7 @@ class Settings(error: String => unit) {
} }
private def guessedScalaExtDirs = { private def guessedScalaExtDirs = {
val scalaHome = System.getProperty("scala.home") val scalaHome = Properties.scalaHome
if (scalaHome ne null) { if (scalaHome ne null) {
val guess = new File(new File(scalaHome), "lib") val guess = new File(new File(scalaHome), "lib")
if (guess.exists()) guess.getPath else null if (guess.exists()) guess.getPath else null