Skip to content

Commit

Permalink
Add separators for compilation cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszwawrzyk committed Jun 15, 2018
1 parent 0ccc1b3 commit 6381827
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object Incremental {
else
incremental.log.debug(
"All initially invalidated classes: " + initialInvClasses + "\n" +
"All initially invalidated sources:" + initialInvSources + "\n")
"All initially invalidated sources: " + initialInvSources + "\n")
val analysis = manageClassfiles(options) { classfileManager =>
incremental.cycle(initialInvClasses,
initialInvSources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private[inc] abstract class IncrementalCommon(val log: sbt.util.Logger, options:
if (invalidatedRaw.isEmpty && modifiedSrcs.isEmpty)
previous
else {
debugOuterSection(s"Recompilation cycle #$cycleNum")
val invalidatedPackageObjects =
this.invalidatedPackageObjects(invalidatedRaw, previous.relations, previous.apis)
if (invalidatedPackageObjects.nonEmpty)
Expand Down Expand Up @@ -111,23 +112,18 @@ private[inc] abstract class IncrementalCommon(val log: sbt.util.Logger, options:
val invalidatedSources = classes.flatMap(previous.relations.definesClass) ++ modifiedSrcs
val invalidatedSourcesForCompilation = expand(invalidatedSources, allSources)
val pruned = Incremental.prune(invalidatedSourcesForCompilation, previous, classfileManager)
debugSection("Pruned")(pruned.relations)
debugInnerSection("Pruned")(pruned.relations)

val fresh = doCompile(invalidatedSourcesForCompilation, binaryChanges)
// For javac as class files are added to classfileManager as they are generated, so
// this step is redundant. For scalac this is still necessary. TODO: do the same for scalac.
classfileManager.generated(fresh.relations.allProducts.toArray)
debugSection("Fresh")(fresh.relations)
debugInnerSection("Fresh")(fresh.relations)
val merged = pruned ++ fresh //.copy(relations = pruned.relations ++ fresh.relations, apis = pruned.apis ++ fresh.apis)
debugSection("Merged")(merged.relations)
debugInnerSection("Merged")(merged.relations)
(merged, invalidatedSourcesForCompilation)
}

private[this] def debugSection(header: String)(content: => Any): Unit = {
import Console._
debug(s"$CYAN************* $header:$RESET\n$content\n$CYAN************* (end of $header)$RESET")
}

private[this] def emptyChanges: DependencyChanges = new DependencyChanges {
val modifiedBinaries = new Array[File](0)
val modifiedClasses = new Array[String](0)
Expand Down Expand Up @@ -338,6 +334,7 @@ private[inc] abstract class IncrementalCommon(val log: sbt.util.Logger, options:
val allInvalidatedClasses = invalidatedClasses ++ byExtSrcDep
val allInvalidatedSourcefiles = addedSrcs ++ modifiedSrcs ++ byProduct ++ byBinaryDep

debugOuterSection(s"Initial invalidation")
if (previous.allSources.isEmpty)
log.debug("Full compilation, no sources in previous analysis.")
else if (allInvalidatedClasses.isEmpty && allInvalidatedSourcefiles.isEmpty)
Expand Down Expand Up @@ -506,4 +503,15 @@ private[inc] abstract class IncrementalCommon(val log: sbt.util.Logger, options:
}
xs.toSet
}

private[this] def debugOuterSection(header: String): Unit = {
import Console._
log.debug(s"$GREEN*************************** $header$RESET")
}

private[this] def debugInnerSection(header: String)(content: => Any): Unit = {
import Console._
debug(s"$CYAN************* $header:$RESET\n$content\n$CYAN************* (end of $header)$RESET")
}

}

0 comments on commit 6381827

Please sign in to comment.