mirror of https://github.com/sbt/sbt.git
Separate location of analysis cache if we're cross compiling scala.
* Add task to determine file-name of analysis cache * If crossPaths := true, then add scala binary version to the analysis cache name. This makes it possible to leverage incremental compilation with the `+` command. Fixes #1267
This commit is contained in:
parent
3aa70b914a
commit
f5dd022551
|
|
@ -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,9 +771,15 @@ 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 := {
|
||||
|
|
|
|||
|
|
@ -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.")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package foo
|
||||
|
||||
object Foo extends App {
|
||||
println("yay")
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
> + compile
|
||||
$ exists target/scala-2.10
|
||||
$ exists target/scala-2.11
|
||||
Loading…
Reference in New Issue