summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2008-08-19 14:29:45 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2008-08-19 14:29:45 +0000
commit56eb012d9f0fb00aa4cec06df32adca5d4cd8d71 (patch)
treef344d0a65e8e806fa3361f3dcbe13647f4f061b1 /src
parent54065c579e343b401c42f126440d1542356b37a1 (diff)
downloadscala-56eb012d9f0fb00aa4cec06df32adca5d4cd8d71.tar.gz
scala-56eb012d9f0fb00aa4cec06df32adca5d4cd8d71.tar.bz2
scala-56eb012d9f0fb00aa4cec06df32adca5d4cd8d71.zip
Added "scalacfork" ant task and enabled it to b...
Added "scalacfork" ant task and enabled it to build locker and quick. Removed sabbus.jar (sabbus ant tasks are included in scala-compiler.jar for some time now) Made serializable, cloneable, SerialVersionUID, BeanProperty static annotations Fixed the Pickler not to crash on repeated annotations
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/ant/sabbus/Make.scala73
-rw-r--r--src/compiler/scala/tools/ant/sabbus/ScalacFork.scala76
-rw-r--r--src/compiler/scala/tools/ant/sabbus/TaskArgs.scala77
-rw-r--r--src/compiler/scala/tools/ant/sabbus/antlib.xml2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala13
-rw-r--r--src/library/scala/SerialVersionUID.scala2
-rw-r--r--src/library/scala/cloneable.scala2
-rw-r--r--src/library/scala/reflect/BeanProperty.scala2
-rw-r--r--src/library/scala/serializable.scala2
9 files changed, 168 insertions, 81 deletions
diff --git a/src/compiler/scala/tools/ant/sabbus/Make.scala b/src/compiler/scala/tools/ant/sabbus/Make.scala
index 21ac55ceb9..958793423d 100644
--- a/src/compiler/scala/tools/ant/sabbus/Make.scala
+++ b/src/compiler/scala/tools/ant/sabbus/Make.scala
@@ -13,77 +13,7 @@ import java.io.File
import org.apache.tools.ant.Task
import org.apache.tools.ant.types.{Path, Reference}
-class Make extends Task {
-
- def setId(input: String): Unit = {
- id = Some(input)
- }
-
- def setParams(input: String): Unit = {
- params = params match {
- case None => Some(input)
- case Some(ps) => Some(ps + " " + input)
- }
- }
-
- def setTarget(input: String): Unit = {
- compTarget = Some(input)
- }
-
- def setCompilationPath(input: Path): Unit = {
- if (compilationPath.isEmpty) compilationPath = Some(input)
- else compilationPath.get.append(input)
- }
-
- def createCompilationPath: Path = {
- if (compilationPath.isEmpty) compilationPath = Some(new Path(getProject()))
- compilationPath.get.createPath()
- }
-
- def setCompilationPathRef(input: Reference): Unit = {
- createCompilationPath.setRefid(input)
- }
-
- def setSrcPath(input: Path): Unit = {
- if (sourcePath.isEmpty) sourcePath = Some(input)
- else sourcePath.get.append(input)
- }
-
- def createSrcPath: Path = {
- if (sourcePath.isEmpty) sourcePath = Some(new Path(getProject()))
- sourcePath.get.createPath()
- }
-
- def setSrcPathRef(input: Reference): Unit = {
- createSrcPath.setRefid(input)
- }
-
- def setCompilerPath(input: Path): Unit = {
- if (compilerPath.isEmpty) compilerPath = Some(input)
- else compilerPath.get.append(input)
- }
-
- def createCompilerPath: Path = {
- if (compilerPath.isEmpty) compilerPath = Some(new Path(getProject()))
- compilerPath.get.createPath()
- }
-
- def setCompilerPathRef(input: Reference): Unit = {
- createCompilerPath.setRefid(input)
- }
-
- def setDestdir(input: File): Unit = {
- destinationDir = Some(input)
- }
-
- private var id: Option[String] = None
- private var params: Option[String] = None
- private var compTarget: Option[String] = None
- private var compilationPath: Option[Path] = None
- private var sourcePath: Option[Path] = None
- private var compilerPath: Option[Path] = None
- private var destinationDir: Option[File] = None
-
+class Make extends Task with TaskArgs {
override def execute: Unit = {
if (id.isEmpty) error("Mandatory attribute 'id' is not set.")
if (compilerPath.isEmpty) error("Mandatory attribute 'compilerpath' is not set.")
@@ -95,5 +25,4 @@ class Make extends Task {
if (!params.isEmpty) settings.more = params.get
Compilers.make(id.get, (compilerPath.get.list.map{ path => new File(path).toURL }), settings)
}
-
}
diff --git a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala
new file mode 100644
index 0000000000..74928ec7ce
--- /dev/null
+++ b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala
@@ -0,0 +1,76 @@
+package scala.tools.ant.sabbus
+
+import java.io.File;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.{MatchingTask, Java}
+import org.apache.tools.ant.util.{GlobPatternMapper, SourceFileScanner}
+
+class ScalacFork extends MatchingTask with TaskArgs {
+ def setSrcdir(input: File) {
+ sourceDir = Some(input)
+ }
+
+ def setFailOnError(input: Boolean): Unit = {
+ failOnError = input
+ }
+
+ def setTimeout(input: Long): Unit = {
+ timeout = Some(input)
+ }
+
+ def setMaxMemory(input: String): Unit = {
+ maxmemory = Some(input)
+ }
+
+ private var sourceDir: Option[File] = None
+ private var failOnError: Boolean = true
+ private var timeout: Option[Long] = None
+ private var maxmemory: Option[String] = None
+
+ override def execute() {
+ if (compilerPath.isEmpty) error("Mandatory attribute 'compilerpath' is not set.")
+ if (sourceDir.isEmpty) error("Mandatory attribute 'srcdir' is not set.")
+ if (destinationDir.isEmpty) error("Mandatory attribute 'destdir' is not set.")
+
+ val settings = new Settings
+ settings.d = destinationDir.get
+ if (!compTarget.isEmpty) settings.target = compTarget.get
+ if (!compilationPath.isEmpty) settings.classpath = compilationPath.get
+ if (!sourcePath.isEmpty) settings.sourcepath = sourcePath.get
+ if (!params.isEmpty) settings.more = params.get
+
+ // not yet used: compilerPath, sourcedir (used in mapper), failonerror, timeout
+
+ val mapper = new GlobPatternMapper()
+ mapper.setTo("*.class")
+ mapper.setFrom("*.scala")
+ val includedFiles: Array[File] =
+ new SourceFileScanner(this).restrict(
+ getDirectoryScanner(sourceDir.get).getIncludedFiles,
+ sourceDir.get,
+ destinationDir.get,
+ mapper
+ ) map (new File(sourceDir.get, _))
+ if (includedFiles.size > 0) {
+ log("Compiling "+ includedFiles.size +" file"+
+ (if (includedFiles.size > 1) "s" else "") +" to "+ destinationDir.get)
+
+ val java = new Java(this) // set this as owner
+ java.setFork(true)
+ java.setClasspath(compilerPath.get)
+ java.setClassname("scala.tools.nsc.Main")
+ if (!timeout.isEmpty) java.setTimeout(timeout.get)
+ if (!maxmemory.isEmpty) java.setMaxmemory(maxmemory.get)
+ for (arg <- settings.toArgs)
+ java.createArg().setValue(arg)
+ for (file <- includedFiles)
+ java.createArg().setFile(file)
+
+ log(java.getCommandLine.getCommandline.mkString("", " ", ""), Project.MSG_VERBOSE)
+ val res = java.executeJava()
+ if (failOnError && res != 0)
+ error("Compilation failed because of an internal compiler error;"+
+ " see the error output for details.")
+ }
+ }
+}
diff --git a/src/compiler/scala/tools/ant/sabbus/TaskArgs.scala b/src/compiler/scala/tools/ant/sabbus/TaskArgs.scala
new file mode 100644
index 0000000000..1ce89120c7
--- /dev/null
+++ b/src/compiler/scala/tools/ant/sabbus/TaskArgs.scala
@@ -0,0 +1,77 @@
+package scala.tools.ant.sabbus
+
+import java.io.File
+import org.apache.tools.ant.Task
+import org.apache.tools.ant.types.{Path, Reference}
+
+trait TaskArgs { this: Task =>
+
+ def setId(input: String): Unit = {
+ id = Some(input)
+ }
+
+ def setParams(input: String): Unit = {
+ params = params match {
+ case None => Some(input)
+ case Some(ps) => Some(ps + " " + input)
+ }
+ }
+
+ def setTarget(input: String): Unit = {
+ compTarget = Some(input)
+ }
+
+ def setCompilationPath(input: Path): Unit = {
+ if (compilationPath.isEmpty) compilationPath = Some(input)
+ else compilationPath.get.append(input)
+ }
+
+ def createCompilationPath: Path = {
+ if (compilationPath.isEmpty) compilationPath = Some(new Path(getProject()))
+ compilationPath.get.createPath()
+ }
+
+ def setCompilationPathRef(input: Reference): Unit = {
+ createCompilationPath.setRefid(input)
+ }
+
+ def setSrcPath(input: Path): Unit = {
+ if (sourcePath.isEmpty) sourcePath = Some(input)
+ else sourcePath.get.append(input)
+ }
+
+ def createSrcPath: Path = {
+ if (sourcePath.isEmpty) sourcePath = Some(new Path(getProject()))
+ sourcePath.get.createPath()
+ }
+
+ def setSrcPathRef(input: Reference): Unit = {
+ createSrcPath.setRefid(input)
+ }
+
+ def setCompilerPath(input: Path): Unit = {
+ if (compilerPath.isEmpty) compilerPath = Some(input)
+ else compilerPath.get.append(input)
+ }
+
+ def createCompilerPath: Path = {
+ if (compilerPath.isEmpty) compilerPath = Some(new Path(getProject()))
+ compilerPath.get.createPath()
+ }
+
+ def setCompilerPathRef(input: Reference): Unit = {
+ createCompilerPath.setRefid(input)
+ }
+
+ def setDestdir(input: File): Unit = {
+ destinationDir = Some(input)
+ }
+
+ protected var id: Option[String] = None
+ protected var params: Option[String] = None
+ protected var compTarget: Option[String] = None
+ protected var compilationPath: Option[Path] = None
+ protected var sourcePath: Option[Path] = None
+ protected var compilerPath: Option[Path] = None
+ protected var destinationDir: Option[File] = None
+}
diff --git a/src/compiler/scala/tools/ant/sabbus/antlib.xml b/src/compiler/scala/tools/ant/sabbus/antlib.xml
index 3388ee00f4..04cd1a8f59 100644
--- a/src/compiler/scala/tools/ant/sabbus/antlib.xml
+++ b/src/compiler/scala/tools/ant/sabbus/antlib.xml
@@ -5,4 +5,6 @@
classname="scala.tools.ant.sabbus.Use"/>
<taskdef name="sabbreak"
classname="scala.tools.ant.sabbus.Break"/>
+ <taskdef name="scalacfork"
+ classname="scala.tools.ant.sabbus.ScalacFork"/>
</antlib> \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index 3f6448300a..c318c08ffb 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -417,11 +417,14 @@ abstract class Pickler extends SubComponent {
}
private def putAnnotation(sym: Symbol, annot: AnnotationInfo) {
- assert(putEntry((sym, annot)))
- val AnnotationInfo(atp, args, assocs) = annot
- putType(atp)
- args foreach putAnnotationArg
- for ((name, c) <- assocs) { putEntry(name); putAnnotationArg(c) }
+ // if an annotation with the same arguments is applied to the
+ // same symbol multiple times, it's only pickled once.
+ if (putEntry((sym, annot))) {
+ val AnnotationInfo(atp, args, assocs) = annot
+ putType(atp)
+ args foreach putAnnotationArg
+ for ((name, c) <- assocs) { putEntry(name); putAnnotationArg(c) }
+ }
}
private def putAnnotation(annot: AnnotationInfo) {
diff --git a/src/library/scala/SerialVersionUID.scala b/src/library/scala/SerialVersionUID.scala
index d75a65a065..34e94a5bb0 100644
--- a/src/library/scala/SerialVersionUID.scala
+++ b/src/library/scala/SerialVersionUID.scala
@@ -16,4 +16,4 @@ package scala
* Annotation for specifying the static SerialVersionUID field
* of a serializable class
*/
-class SerialVersionUID(uid: Long) extends Annotation
+class SerialVersionUID(uid: Long) extends StaticAnnotation
diff --git a/src/library/scala/cloneable.scala b/src/library/scala/cloneable.scala
index 7853f604be..1fd88e4765 100644
--- a/src/library/scala/cloneable.scala
+++ b/src/library/scala/cloneable.scala
@@ -14,4 +14,4 @@ package scala
/**
* An annotation that designates the class to which it is applied as cloneable
*/
-class cloneable extends Annotation
+class cloneable extends StaticAnnotation
diff --git a/src/library/scala/reflect/BeanProperty.scala b/src/library/scala/reflect/BeanProperty.scala
index 4a09578df9..88d17208a5 100644
--- a/src/library/scala/reflect/BeanProperty.scala
+++ b/src/library/scala/reflect/BeanProperty.scala
@@ -30,4 +30,4 @@ package scala.reflect
* you should use the normal Scala access and assignment.
* </p>
*/
-class BeanProperty extends Annotation
+class BeanProperty extends StaticAnnotation
diff --git a/src/library/scala/serializable.scala b/src/library/scala/serializable.scala
index f96c36a155..50f59928f6 100644
--- a/src/library/scala/serializable.scala
+++ b/src/library/scala/serializable.scala
@@ -15,4 +15,4 @@ package scala
/**
* An annotation that designates the class to which it is applied as serializable
*/
-class serializable extends Annotation {}
+class serializable extends StaticAnnotation {}