From f9a7a0a28ef3ff3e02de0c9ca4a37a92843bdfb9 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sun, 27 Jun 2010 09:16:53 -0400 Subject: [PATCH] Set -> Seq for sources, classpaths --- compile/AnalyzingCompiler.scala | 10 +++++++--- compile/CompilerArguments.scala | 9 +++++---- compile/ComponentCompiler.scala | 2 +- compile/RawCompiler.scala | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/compile/AnalyzingCompiler.scala b/compile/AnalyzingCompiler.scala index 003d711df..142712d6e 100644 --- a/compile/AnalyzingCompiler.scala +++ b/compile/AnalyzingCompiler.scala @@ -12,19 +12,23 @@ package xsbt class AnalyzingCompiler(val scalaInstance: ScalaInstance, val manager: ComponentManager, val cp: ClasspathOptions, log: CompileLogger) extends NotNull { def this(scalaInstance: ScalaInstance, manager: ComponentManager, log: CompileLogger) = this(scalaInstance, manager, ClasspathOptions.auto, log) - def apply(sources: Set[File], classpath: Set[File], outputDirectory: File, options: Seq[String], callback: AnalysisCallback, maximumErrors: Int, log: CompileLogger) + def apply(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String], callback: AnalysisCallback, maximumErrors: Int, log: CompileLogger) { val arguments = (new CompilerArguments(scalaInstance, cp))(sources, classpath, outputDirectory, options) + compile(arguments, callback, maximumErrors, log) + } + def compile(arguments: Seq[String], callback: AnalysisCallback, maximumErrors: Int, log: CompileLogger) + { call("xsbt.CompilerInterface", log)( classOf[Array[String]], classOf[AnalysisCallback], classOf[Int], classOf[xLogger] ) ( arguments.toArray[String] : Array[String], callback, maximumErrors: java.lang.Integer, log ) } - def doc(sources: Set[File], classpath: Set[File], outputDirectory: File, options: Seq[String], maximumErrors: Int, log: CompileLogger): Unit = + def doc(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String], maximumErrors: Int, log: CompileLogger): Unit = { val arguments = (new CompilerArguments(scalaInstance, cp))(sources, classpath, outputDirectory, options) call("xsbt.ScaladocInterface", log) (classOf[Array[String]], classOf[Int], classOf[xLogger]) (arguments.toArray[String] : Array[String], maximumErrors: java.lang.Integer, log) } - def console(classpath: Set[File], options: Seq[String], initialCommands: String, log: CompileLogger): Unit = + def console(classpath: Seq[File], options: Seq[String], initialCommands: String, log: CompileLogger): Unit = { val arguments = new CompilerArguments(scalaInstance, cp) val classpathString = CompilerArguments.absString(arguments.finishClasspath(classpath)) diff --git a/compile/CompilerArguments.scala b/compile/CompilerArguments.scala index cd27b15b5..6e1bc5451 100644 --- a/compile/CompilerArguments.scala +++ b/compile/CompilerArguments.scala @@ -10,19 +10,18 @@ package xsbt * this would lead to compiling against the wrong library jar.*/ class CompilerArguments(scalaInstance: ScalaInstance, cp: ClasspathOptions) extends NotNull { - def apply(sources: Set[File], classpath: Set[File], outputDirectory: File, options: Seq[String]): Seq[String] = + def apply(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String]): Seq[String] = { checkScalaHomeUnset() - val bootClasspathOption = if(cp.autoBoot) Seq("-bootclasspath", createBootClasspath) else Nil val cpWithCompiler = finishClasspath(classpath) val classpathOption = Seq("-cp", absString(cpWithCompiler) ) val outputOption = Seq("-d", outputDirectory.getAbsolutePath) options ++ outputOption ++ bootClasspathOption ++ classpathOption ++ abs(sources) } - def finishClasspath(classpath: Set[File]): Set[File] = + def finishClasspath(classpath: Seq[File]): Seq[File] = classpath ++ include(cp.compiler, scalaInstance.compilerJar) ++ include(cp.extra, scalaInstance.extraJars : _*) private def include(flag: Boolean, jars: File*) = if(flag) jars else Nil - protected def abs(files: Set[File]) = files.map(_.getAbsolutePath).toList.sortWith(_ < _) + protected def abs(files: Seq[File]) = files.map(_.getAbsolutePath).sortWith(_ < _) protected def checkScalaHomeUnset() { val scalaHome = System.getProperty("scala.home") @@ -35,6 +34,8 @@ class CompilerArguments(scalaInstance: ScalaInstance, cp: ClasspathOptions) exte val newBootPrefix = if(originalBoot.isEmpty) "" else originalBoot + File.pathSeparator newBootPrefix + scalaInstance.libraryJar.getAbsolutePath } + def bootClasspathOption = if(cp.autoBoot) Seq("-bootclasspath", createBootClasspath) else Nil + def bootClasspath = if(cp.autoBoot) sbt.IO.pathSplit(createBootClasspath).map(new File(_)).toSeq else Nil } class ClasspathOptions(val autoBoot: Boolean, val compiler: Boolean, val extra: Boolean) extends NotNull object ClasspathOptions diff --git a/compile/ComponentCompiler.scala b/compile/ComponentCompiler.scala index b36a33bb8..d6f14c4e7 100644 --- a/compile/ComponentCompiler.scala +++ b/compile/ComponentCompiler.scala @@ -64,7 +64,7 @@ class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager) val start = System.currentTimeMillis try { - compiler(Set() ++ sourceFiles, Set() ++ xsbtiJars ++ sourceJars, outputDirectory, "-nowarn" :: Nil) + compiler(sourceFiles.toSeq, xsbtiJars.toSeq ++ sourceJars, outputDirectory, "-nowarn" :: Nil) manager.log.info(" Compilation completed in " + (System.currentTimeMillis - start) / 1000.0 + " s") } catch { case e: xsbti.CompileFailed => throw new CompileFailed(e.arguments, "Error compiling sbt component '" + id + "'") } diff --git a/compile/RawCompiler.scala b/compile/RawCompiler.scala index 6b25079fc..5b78a445b 100644 --- a/compile/RawCompiler.scala +++ b/compile/RawCompiler.scala @@ -8,7 +8,7 @@ package xsbt * the scala-library.jar from `scalaInstance` is put on bootclasspath and the scala-compiler jar goes on the classpath.*/ class RawCompiler(val scalaInstance: ScalaInstance, cp: ClasspathOptions, log: CompileLogger) { - def apply(sources: Set[File], classpath: Set[File], outputDirectory: File, options: Seq[String]) + def apply(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String]) { // reflection is required for binary compatibility // The following import ensures there is a compile error if the identifiers change,