Break compiler dependency from 'collection' project.

This commit is contained in:
Eugene Vigdorchik 2012-07-10 20:51:34 +04:00 committed by Mark Harrah
parent 82a338b3a8
commit a6c2054292
6 changed files with 18 additions and 16 deletions

View File

@ -6,7 +6,6 @@ package inc
import xsbti.api.Source
import java.io.File
import sbt.Util.counted
trait Analysis
{
@ -46,6 +45,15 @@ object Analysis
counted("unreported warning", "", "s", unreportedCount)
sections.mkString("Analysis: ", ", ", "")
}
def counted(prefix: String, single: String, plural: String, count: Int): Option[String] =
count match
{
case 0 => None
case 1 => Some("1 " + prefix + single)
case x => Some(x.toString + " " + prefix + plural)
}
}
private class MAnalysis(val stamps: Stamps, val apis: APIs, val relations: Relations, val infos: SourceInfos) extends Analysis
{
@ -73,4 +81,4 @@ private class MAnalysis(val stamps: Stamps, val apis: APIs, val relations: Relat
def addProduct(src: File, product: File, stamp: Stamp, name: String): Analysis =
copy( stamps.markProduct(product, stamp), apis, relations.addProduct(src, product, name), infos )
}
}

View File

@ -12,7 +12,6 @@ import inc._
import inc.Locate.DefinesClass
import CompileSetup._
import sbinary.DefaultProtocol.{ immutableMapFormat, immutableSetFormat, StringFormat }
import Types.const
import xsbti.AnalysisCallback
import xsbti.api.Source
@ -25,7 +24,7 @@ final class CompileConfiguration(val sources: Seq[File], val classpath: Seq[File
class AggressiveCompile(cacheFile: File)
{
def apply(compiler: AnalyzingCompiler, javac: xsbti.compile.JavaCompiler, sources: Seq[File], classpath: Seq[File], outputDirectory: File, cache: GlobalsCache, options: Seq[String] = Nil, javacOptions: Seq[String] = Nil, analysisMap: File => Option[Analysis] = const(None), definesClass: DefinesClass = Locate.definesClass _, maxErrors: Int = 100, compileOrder: CompileOrder = Mixed, skip: Boolean = false)(implicit log: Logger): Analysis =
def apply(compiler: AnalyzingCompiler, javac: xsbti.compile.JavaCompiler, sources: Seq[File], classpath: Seq[File], outputDirectory: File, cache: GlobalsCache, options: Seq[String] = Nil, javacOptions: Seq[String] = Nil, analysisMap: File => Option[Analysis] = { _ => None }, definesClass: DefinesClass = Locate.definesClass _, maxErrors: Int = 100, compileOrder: CompileOrder = Mixed, skip: Boolean = false)(implicit log: Logger): Analysis =
{
val setup = new CompileSetup(outputDirectory, new CompileOptions(options, javacOptions), compiler.scalaInstance.actualVersion, compileOrder)
compile1(sources, classpath, setup, store, analysisMap, definesClass, compiler, javac, maxErrors, skip, cache)
@ -105,8 +104,8 @@ class AggressiveCompile(cacheFile: File)
}
private[this] def logInputs(log: Logger, javaCount: Int, scalaCount: Int, out: File)
{
val scalaMsg = Util.counted("Scala source", "", "s", scalaCount)
val javaMsg = Util.counted("Java source", "", "s", javaCount)
val scalaMsg = Analysis.counted("Scala source", "", "s", scalaCount)
val javaMsg = Analysis.counted("Java source", "", "s", javaCount)
val combined = scalaMsg ++ javaMsg
if(!combined.isEmpty)
log.info(combined.mkString("Compiling ", " and ", " to " + out.getAbsolutePath + "..."))

View File

@ -63,6 +63,8 @@ object Sbt extends Build
lazy val completeSub = testedBaseProject(utilPath / "complete", "Completion") dependsOn(collectionSub, controlSub, ioSub) settings(jline)
// logging
lazy val logSub = testedBaseProject(utilPath / "log", "Logging") dependsOn(interfaceSub, processSub) settings(libraryDependencies += jlineDep % "optional")
// Relation
lazy val relationSub = testedBaseProject(utilPath / "relation", "Relation") dependsOn(interfaceSub, processSub)
// class file reader and analyzer
lazy val classfileSub = testedBaseProject(utilPath / "classfile", "Classfile") dependsOn(ioSub, interfaceSub, logSub)
// generates immutable or mutable Java data types according to a simple input format
@ -98,7 +100,7 @@ object Sbt extends Build
// Implements the core functionality of detecting and propagating changes incrementally.
// Defines the data structures for representing file fingerprints and relationships and the overall source analysis
lazy val compileIncrementalSub = testedBaseProject(compilePath / "inc", "Incremental Compiler") dependsOn(collectionSub, apiSub, ioSub, logSub, classpathSub)
lazy val compileIncrementalSub = testedBaseProject(compilePath / "inc", "Incremental Compiler") dependsOn(apiSub, ioSub, logSub, classpathSub, relationSub)
// Persists the incremental data structures using SBinary
lazy val compilePersistSub = baseProject(compilePath / "persist", "Persist") dependsOn(compileIncrementalSub, apiSub) settings(sbinary)
// sbt-side interface to compiler. Calls compiler-side interface reflectively
@ -116,7 +118,7 @@ object Sbt extends Build
// Implementation and support code for defining actions.
lazy val actionsSub = baseProject(mainPath / "actions", "Actions") dependsOn(
classpathSub, completeSub, apiSub, compilerIntegrationSub, compilerIvySub,
interfaceSub, ioSub, ivySub, logSub, processSub, runSub, stdTaskSub, taskSub, trackingSub, testingSub)
interfaceSub, ioSub, ivySub, logSub, processSub, runSub, relationSub, stdTaskSub, taskSub, trackingSub, testingSub)
lazy val commandSub = testedBaseProject(commandPath, "Command") dependsOn(interfaceSub, ioSub, launchInterfaceSub, logSub, completeSub, classpathSub)

View File

@ -20,13 +20,6 @@ object Util
case Left(l) => (l +: acc._1, acc._2)
case Right(r) => (acc._1, r +: acc._2)
}
def counted(prefix: String, single: String, plural: String, count: Int): Option[String] =
count match
{
case 0 => None
case 1 => Some("1 " + prefix + single)
case x => Some(x.toString + " " + prefix + plural)
}
def pairID[A,B] = (a: A, b: B) => (a,b)
}

View File

@ -119,4 +119,4 @@ private final class MRelation[A,B](fwd: Map[A, Set[B]], rev: Map[B, Set[A]]) ext
def contains(a: A, b: B): Boolean = forward(a)(b)
override def toString = all.map { case (a,b) => a + " -> " + b }.mkString("Relation [", ", ", "]")
}
}