diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2008-08-19 14:29:45 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2008-08-19 14:29:45 +0000 |
commit | 56eb012d9f0fb00aa4cec06df32adca5d4cd8d71 (patch) | |
tree | f344d0a65e8e806fa3361f3dcbe13647f4f061b1 /src/compiler/scala/tools/ant/sabbus/ScalacFork.scala | |
parent | 54065c579e343b401c42f126440d1542356b37a1 (diff) | |
download | scala-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/compiler/scala/tools/ant/sabbus/ScalacFork.scala')
-rw-r--r-- | src/compiler/scala/tools/ant/sabbus/ScalacFork.scala | 76 |
1 files changed, 76 insertions, 0 deletions
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.") + } + } +} |