Skip to content

Commit

Permalink
handle custom -bootclasspath in incremental recompilation
Browse files Browse the repository at this point in the history
  • Loading branch information
harrah committed Aug 4, 2011
1 parent a19d5a7 commit 980e906
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions compile/CompilerArguments.scala
Expand Up @@ -5,7 +5,7 @@ package sbt
package compiler

import java.io.File
import CompilerArguments.{abs, absString}
import CompilerArguments.{abs, absString, BootClasspathOption}

/** Forms the list of options that is passed to the compiler from the required inputs and other options.
* The directory containing scala-library.jar and scala-compiler.jar (scalaLibDirectory) is required in
Expand Down Expand Up @@ -45,11 +45,12 @@ final class CompilerArguments(scalaInstance: ScalaInstance, cp: ClasspathOptions
}
def filterLibrary(classpath: Seq[File]) =
if(cp.filterLibrary) classpath.filterNot(_.getName contains ScalaArtifacts.LibraryID) else classpath
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
def bootClasspathOption = if(cp.autoBoot) Seq(BootClasspathOption, createBootClasspath) else Nil
def bootClasspath = if(cp.autoBoot) IO.parseClasspath(createBootClasspath) else Nil
}
object CompilerArguments
{
val BootClasspathOption = "-bootclasspath"
def abs(files: Seq[File]): Seq[String] = files.map(_.getAbsolutePath)
def abs(files: Set[File]): Seq[String] = abs(files.toSeq)
def absString(files: Seq[File]): String = abs(files).mkString(File.pathSeparator)
Expand Down
5 changes: 4 additions & 1 deletion main/actions/AggressiveCompile.scala
Expand Up @@ -55,7 +55,7 @@ class AggressiveCompile(cacheDirectory: File)
val absClasspath = classpath.map(_.getCanonicalFile)
val apiOption= (api: Either[Boolean, Source]) => api.right.toOption
val cArgs = new CompilerArguments(compiler.scalaInstance, compiler.cp)
val searchClasspath = withBootclasspath(cArgs, absClasspath)
val searchClasspath = explicitBootClasspath(options.options) ++ withBootclasspath(cArgs, absClasspath)
val entry = Locate.entry(searchClasspath, definesClass)

val compile0 = (include: Set[File], callback: AnalysisCallback) => {
Expand Down Expand Up @@ -106,6 +106,9 @@ class AggressiveCompile(cacheDirectory: File)
}
def javaOnly(f: File) = f.getName.endsWith(".java")

private[this] def explicitBootClasspath(options: Seq[String]): Seq[File] =
options.dropWhile(_ != CompilerArguments.BootClasspathOption).drop(1).take(1).headOption.toList.flatMap(IO.parseClasspath)

import AnalysisFormats._
val store = AggressiveCompile.staticCache(cacheDirectory, AnalysisStore.sync(AnalysisStore.cached(FileBasedStore(cacheDirectory))))
}
Expand Down
2 changes: 2 additions & 0 deletions util/io/IO.scala
Expand Up @@ -627,4 +627,6 @@ object IO
}
def assertAbsolute(f: File) = assert(f.isAbsolute, "Not absolute: " + f)
def assertAbsolute(uri: URI) = assert(uri.isAbsolute, "Not absolute: " + uri)

def parseClasspath(s: String): Seq[File] = IO.pathSplit(s).map(new File(_)).toSeq
}

0 comments on commit 980e906

Please sign in to comment.