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}"/>
<!-- Defines the product being built -->
<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"/>
<!-- Configuring how the compiler is run -->
<property name="nsc.log-files" value="no"/>
@ -64,6 +64,7 @@ PROPERTIES
<property name="scalac.exec.name" value="scalac"/>
<property name="scaladoc.exec.name" value="scaladoc"/>
<property name="fsc.exec.name" value="fsc"/>
<property name="comp.prop.name" value="compiler.properties"/>
<!-- ===========================================================================
INITIALISATION
@ -317,6 +318,16 @@ BUILD LOCAL REFERENCE (LOCKER) LAYER
<include name="**/*.scala"/>
<excludesfile name="${nsc.excludes.file}" if="excludes.avail"/>
</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 -->
<stopwatch name="timer.locker" action="total"/>
<!-- Copy support files to build folder and links external libraries-->
@ -451,6 +462,16 @@ BUILD QUICK-TEST LAYER
<include name="**/*.scala"/>
<excludesfile name="${nsc.excludes.file}" if="excludes.avail"/>
</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 -->
<stopwatch name="timer.quick" action="total"/>
<!-- Copy support files to build folder and links external libraries-->
@ -585,6 +606,17 @@ TEST
<include name="**/*.scala"/>
<excludesfile name="${nsc.excludes.file}" if="excludes.avail"/>
</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 -->
<stopwatch name="timer.strap" action="total"/>
<!-- Copy support files to build folder and links external libraries-->

View File

@ -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()

View File

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

View File

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

View File

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

View File

@ -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)

View File

@ -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)

View File

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

View File

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

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
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