From e33a70721e4c147bfc316f3e6d1bcd058021805c Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 24 Mar 2009 18:10:59 +0000 Subject: reverting my previous pointless change and movi... reverting my previous pointless change and moving it to where it makes some sense (ScalacFork) --- src/compiler/scala/tools/ant/Scalac.scala | 24 +++++----------------- .../scala/tools/ant/sabbus/ScalacFork.scala | 14 +++++++++++-- 2 files changed, 17 insertions(+), 21 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index a7ff39ec0e..f4cbcf1bf8 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -18,7 +18,7 @@ import org.apache.tools.ant.types.{Path, Reference} import org.apache.tools.ant.util.{FileUtils, GlobPatternMapper, SourceFileScanner} -import scala.tools.nsc.{Global, Settings, CompilerCommand} +import scala.tools.nsc.{Global, Settings} import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} /**

@@ -157,9 +157,6 @@ class Scalac extends MatchingTask { * (not only the number of files). */ protected var scalacDebugging: Boolean = false - /** An optional file containing compiler arguments */ - protected var argfile: Option[File] = None - /*============================================================================*\ ** Properties setters ** \*============================================================================*/ @@ -352,10 +349,6 @@ class Scalac extends MatchingTask { def setAssemrefs(input: String) { assemrefs = Some(input) } - - /** Sets the argfile attribute. */ - def setArgfile(input: File) { argfile = Some(input) } - /*============================================================================*\ ** Properties getters ** \*============================================================================*/ @@ -464,7 +457,6 @@ class Scalac extends MatchingTask { protected def newSettings(error: String=>Unit): Settings = new Settings(error) - protected def newGlobal(settings: Settings, reporter: Reporter) = new Global(settings, reporter) @@ -474,7 +466,7 @@ class Scalac extends MatchingTask { \*============================================================================*/ /** Initializes settings and source files */ - protected def initialize: (Settings, List[String], Boolean) = { + protected def initialize: (Settings, List[File], Boolean) = { // Tests if all mandatory attributes are set and valid. if (origin.isEmpty) error("Attribute 'srcdir' is not set.") if (getOrigin.isEmpty) error("Attribute 'srcdir' is not set.") @@ -491,7 +483,7 @@ class Scalac extends MatchingTask { // Scans source directories to build up a compile lists. // If force is false, only files were the .class file in destination is // older than the .scala file will be used. - var sourceFiles: List[String] = + val sourceFiles: List[File] = for { val originDir <- getOrigin val originFiles <- { @@ -529,18 +521,12 @@ class Scalac extends MatchingTask { } yield { log(originFiles, Project.MSG_DEBUG) - nameToFile(originDir)(originFiles).toString + nameToFile(originDir)(originFiles) } // Builds-up the compilation settings for Scalac with the existing Ant // parameters. val settings = newSettings(error) - if (!argfile.isEmpty) { - log("Using argument file: @" +argfile.get) - javaOnly = false // not quite correct, depends on content of argfile - val command = new CompilerCommand(List("@"+ argfile.get), settings, error, true) - sourceFiles = sourceFiles ::: command.files - } settings.outdir.value = asString(destination.get) if (!classpath.isEmpty) settings.classpath.value = asString(getClasspath) @@ -586,7 +572,7 @@ class Scalac extends MatchingTask { // Compiles the actual code val compiler = newGlobal(settings, reporter) try { - (new compiler.Run).compile(sourceFiles) + (new compiler.Run).compile(sourceFiles.map (_.toString)) } catch { case exception: Throwable if (exception.getMessage ne null) => diff --git a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala index f70400fea8..e68304d2f5 100644 --- a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala +++ b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala @@ -32,10 +32,15 @@ class ScalacFork extends MatchingTask with TaskArgs { jvmArgs = Some(input) } + def setArgfile(input: File) { + argfile = Some(input) + } + private var sourceDir: Option[File] = None private var failOnError: Boolean = true private var timeout: Option[Long] = None private var jvmArgs: Option[String] = None + private var argfile: Option[File] = None override def execute() { if (compilerPath.isEmpty) error("Mandatory attribute 'compilerpath' is not set.") @@ -61,9 +66,12 @@ class ScalacFork extends MatchingTask with TaskArgs { destinationDir.get, mapper ) map (new File(sourceDir.get, _)) - if (includedFiles.size > 0) { - log("Compiling "+ includedFiles.size +" file"+ + if (includedFiles.size > 0 || argfile.isDefined) { + if (includedFiles.size > 0) + log("Compiling "+ includedFiles.size +" file"+ (if (includedFiles.size > 1) "s" else "") +" to "+ destinationDir.get) + if (argfile.isDefined) + log("Using argument file: @"+ argfile.get) val java = new Java(this) // set this as owner java.setFork(true) @@ -76,6 +84,8 @@ class ScalacFork extends MatchingTask with TaskArgs { java.createArg().setValue(arg) for (file <- includedFiles) java.createArg().setFile(file) + for (af <- argfile) + java.createArg().setValue("@"+ af) log(java.getCommandLine.getCommandline.mkString("", " ", ""), Project.MSG_VERBOSE) val res = java.executeJava() -- cgit v1.2.3