Add Ant-style incremental compilation mode.

This commit implements an Ant-style incremental compilation mode. This mode
emulates what Ant's scalac command does. It recompiles just changed source
files and does not perform any invalidation of dependencies.
This is a very naive mode of incremental compilation that very often leads
to broken binaries.

The Ant-style mode is being introduced because Scala team needs it for
migration of Scala compiler to sbt. The name hashing algorithm doesn't
work well with Scala compiler sources due to deep inheritance chains.
There's a plan to refactor compiler's code to use more composition instead
of inheritance.

Once Scala compiler sources are refactored to work well with name hashing
algorithm, Ant-style mode will be deleted immediately.
This commit is contained in:
Grzegorz Kossakowski 2014-05-08 20:26:22 +02:00
parent ba88236b31
commit 680713f666
3 changed files with 25 additions and 4 deletions

View File

@ -21,10 +21,12 @@ object Incremental {
options: IncOptions)(implicit equivS: Equiv[Stamp]): (Boolean, Analysis) =
{
val incremental: IncrementalCommon =
if (!options.nameHashing)
new IncrementalDefaultImpl(log, options)
else
if (options.nameHashing)
new IncrementalNameHashing(log, options)
else if (options.antStyle)
new IncrementalAntStyle(log, options)
else
new IncrementalDefaultImpl(log, options)
val initialChanges = incremental.changedInitial(entry, sources, previous, current, forEntry)
val binaryChanges = new DependencyChanges {
val modifiedBinaries = initialChanges.binaryDeps.toArray
@ -573,3 +575,22 @@ private final class IncrementalNameHashing(log: Logger, options: IncOptions) ext
f => relations.memberRef.internal.reverse(f)
}
private final class IncrementalAntStyle(log: Logger, options: IncOptions) extends IncrementalCommon(log, options) {
/** Ant-style mode doesn't do anything special with package objects */
override protected def invalidatedPackageObjects(invalidated: Set[File], relations: Relations): Set[File] = Set.empty
/** In Ant-style mode we don't need to compare APIs because we don't perform any invalidation */
override protected def sameAPI[T](src: T, a: Source, b: Source): Option[APIChange[T]] = None
/** In Ant-style mode we don't perform any invalidation */
override protected def invalidateByExternal(relations: Relations, externalAPIChange: APIChange[String]): Set[File] = Set.empty
/** In Ant-style mode we don't perform any invalidation */
override protected def invalidateSource(relations: Relations, change: APIChange[File]): Set[File] = Set.empty
/** In Ant-style mode we don't need to perform any dependency analysis hence we can always return an empty set. */
override protected def allDeps(relations: Relations): File => Set[File] = _ => Set.empty
}

View File

@ -1,6 +1,6 @@
logLevel := Level.Debug
incOptions := incOptions.value.withNameHashing(true)
incOptions := incOptions.value.withAntStyle(true)
/* Performs checks related to compilations:
* a) checks in which compilation given set of files was recompiled