Merge pull request #1277 from sbt/fix/issue-1267

Separate location of analysis cache if we're cross compiling scala.
This commit is contained in:
eugene yokota 2014-04-22 13:45:49 -04:00
commit 9d86d56797
5 changed files with 40 additions and 4 deletions

View File

@ -246,6 +246,14 @@ object Defaults extends BuildCommon
lazy val configTasks = docTaskSettings(doc) ++ inTask(compile)(compileInputsSettings) ++ configGlobal ++ Seq(
compile <<= compileTask tag(Tags.Compile, Tags.CPU),
printWarnings <<= printWarningsTask,
compileAnalysisFilename := {
// Here, if the user wants cross-scala-versioning, we also append it
// to the analysis cache, so we keep the scala versions separated.
val extra =
if(crossPaths.value) s"_${scalaBinaryVersion.value}"
else ""
s"inc_compile${extra}"
},
compileIncSetup <<= compileIncSetupTask,
console <<= consoleTask,
consoleQuick <<= consoleQuickTask,
@ -763,10 +771,16 @@ object Defaults extends BuildCommon
}
finally x.close() // workaround for #937
}
def compileIncSetupTask =
(dependencyClasspath, skip in compile, definesClass, compilerCache, streams, incOptions) map { (cp, skip, definesC, cache, s, incOptions) =>
Compiler.IncSetup(analysisMap(cp), definesC, skip, s.cacheDirectory / "inc_compile", cache, incOptions)
}
def compileIncSetupTask = Def.task {
Compiler.IncSetup(
analysisMap(dependencyClasspath.value),
definesClass.value,
(skip in compile).value,
// TODO - this is kind of a bad way to grab the cache directory for streams...
streams.value.cacheDirectory / compileAnalysisFilename.value,
compilerCache.value,
incOptions.value)
}
def compileInputsSettings: Seq[Setting[_]] =
Seq(compileInputs := {
val cp = classDirectory.value +: data(dependencyClasspath.value)

View File

@ -142,6 +142,7 @@ object Keys
val consoleProject = TaskKey[Unit]("console-project", "Starts the Scala interpreter with the sbt and the build definition on the classpath and useful imports.", AMinusTask)
val compile = TaskKey[Analysis]("compile", "Compiles sources.", APlusTask)
val compilers = TaskKey[Compiler.Compilers]("compilers", "Defines the Scala and Java compilers to use for compilation.", DTask)
val compileAnalysisFilename = TaskKey[String]("compileAnalysisFilename", "Defines the filename used to store the incremental compiler analysis file (inside the streams cacheDirectory).", DTask)
val compileIncSetup = TaskKey[Compiler.IncSetup]("inc-compile-setup", "Configures aspects of incremental compilation.", DTask)
val compilerCache = TaskKey[GlobalsCache]("compiler-cache", "Cache of scala.tools.nsc.Global instances. This should typically be cached so that it isn't recreated every task run.", DTask)
val stateCompilerCache = AttributeKey[GlobalsCache]("compiler-cache", "Internal use: Global cache.")

View File

@ -0,0 +1,12 @@
name := "foo"
scalaVersion := "2.10.4"
crossScalaVersions := List("2.10.4", "2.11.0")
incOptions := incOptions.value.withNewClassfileManager(
sbt.inc.ClassfileManager.transactional(
crossTarget.value / "classes.bak",
(streams in (Compile, compile)).value.log
)
)

View File

@ -0,0 +1,6 @@
package foo
object Foo extends App {
println("yay")
}

View File

@ -0,0 +1,3 @@
> + compile
$ exists target/scala-2.10
$ exists target/scala-2.11