mirror of https://github.com/sbt/sbt.git
Use `IncOptions` for `transitiveStep` and `recompileAllFraction`
Recently introduced IncOptions allow us to make both transitiveStep and recompileAllFraction configurable in incremental compiler.
This commit is contained in:
parent
70036812ab
commit
f3d2df0f9c
|
|
@ -12,10 +12,6 @@ import java.io.File
|
||||||
|
|
||||||
object Incremental
|
object Incremental
|
||||||
{
|
{
|
||||||
// to be configurable
|
|
||||||
final val TransitiveStep = 2
|
|
||||||
final val RecompileAllFraction = 0.5
|
|
||||||
|
|
||||||
def compile(sources: Set[File],
|
def compile(sources: Set[File],
|
||||||
entry: String => Option[File],
|
entry: String => Option[File],
|
||||||
previous: Analysis,
|
previous: Analysis,
|
||||||
|
|
@ -49,7 +45,7 @@ object Incremental
|
||||||
{
|
{
|
||||||
def debug(s: => String) = if (incDebug(options)) log.debug(s) else ()
|
def debug(s: => String) = if (incDebug(options)) log.debug(s) else ()
|
||||||
val withPackageObjects = invalidatedRaw ++ invalidatedPackageObjects(invalidatedRaw, previous.relations)
|
val withPackageObjects = invalidatedRaw ++ invalidatedPackageObjects(invalidatedRaw, previous.relations)
|
||||||
val invalidated = expand(withPackageObjects, allSources, log)
|
val invalidated = expand(withPackageObjects, allSources, log, options)
|
||||||
val pruned = prune(invalidated, previous)
|
val pruned = prune(invalidated, previous)
|
||||||
debug("********* Pruned: \n" + pruned.relations + "\n*********")
|
debug("********* Pruned: \n" + pruned.relations + "\n*********")
|
||||||
val fresh = doCompile(invalidated, binaryChanges)
|
val fresh = doCompile(invalidated, binaryChanges)
|
||||||
|
|
@ -58,7 +54,8 @@ object Incremental
|
||||||
debug("********* Merged: \n" + merged.relations + "\n*********")
|
debug("********* Merged: \n" + merged.relations + "\n*********")
|
||||||
val incChanges = changedIncremental(invalidated, previous.apis.internalAPI _, merged.apis.internalAPI _, options)
|
val incChanges = changedIncremental(invalidated, previous.apis.internalAPI _, merged.apis.internalAPI _, options)
|
||||||
debug("Changes:\n" + incChanges)
|
debug("Changes:\n" + incChanges)
|
||||||
val incInv = invalidateIncremental(merged.relations, incChanges, invalidated, cycleNum >= TransitiveStep, log)
|
val transitiveStep = options.transitiveStep
|
||||||
|
val incInv = invalidateIncremental(merged.relations, incChanges, invalidated, cycleNum >= transitiveStep, log)
|
||||||
cycle(incInv, allSources, emptyChanges, merged, doCompile, cycleNum+1, log, options)
|
cycle(incInv, allSources, emptyChanges, merged, doCompile, cycleNum+1, log, options)
|
||||||
}
|
}
|
||||||
private[this] def emptyChanges: DependencyChanges = new DependencyChanges {
|
private[this] def emptyChanges: DependencyChanges = new DependencyChanges {
|
||||||
|
|
@ -66,12 +63,14 @@ object Incremental
|
||||||
val modifiedClasses = new Array[String](0)
|
val modifiedClasses = new Array[String](0)
|
||||||
def isEmpty = true
|
def isEmpty = true
|
||||||
}
|
}
|
||||||
private[this] def expand(invalidated: Set[File], all: Set[File], log: Logger): Set[File] =
|
private[this] def expand(invalidated: Set[File], all: Set[File], log: Logger, options: IncOptions): Set[File] = {
|
||||||
if(invalidated.size > all.size * RecompileAllFraction) {
|
val recompileAllFraction = options.recompileAllFraction
|
||||||
log.debug("Recompiling all " + all.size + " sources: invalidated sources (" + invalidated.size + ") exceeded " + (RecompileAllFraction*100.0) + "% of all sources")
|
if(invalidated.size > all.size * recompileAllFraction) {
|
||||||
|
log.debug("Recompiling all " + all.size + " sources: invalidated sources (" + invalidated.size + ") exceeded " + (recompileAllFraction*100.0) + "% of all sources")
|
||||||
all ++ invalidated // need the union because all doesn't contain removed sources
|
all ++ invalidated // need the union because all doesn't contain removed sources
|
||||||
}
|
}
|
||||||
else invalidated
|
else invalidated
|
||||||
|
}
|
||||||
|
|
||||||
// Package objects are fragile: if they depend on an invalidated source, get "class file needed by package is missing" error
|
// Package objects are fragile: if they depend on an invalidated source, get "class file needed by package is missing" error
|
||||||
// This might be too conservative: we probably only need package objects for packages of invalidated sources.
|
// This might be too conservative: we probably only need package objects for packages of invalidated sources.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue