mirror of https://github.com/sbt/sbt.git
memoize aggregation, cleanup
This commit is contained in:
parent
58473dedcb
commit
07dbba65d1
|
|
@ -41,7 +41,7 @@ class AnalyzingCompiler(val scalaInstance: ScalaInstance, val manager: Component
|
||||||
def console(classpath: Seq[File], options: Seq[String], initialCommands: String, log: Logger)(loader: Option[ClassLoader] = None, bindings: Seq[(String, Any)] = Nil): Unit =
|
def console(classpath: Seq[File], options: Seq[String], initialCommands: String, log: Logger)(loader: Option[ClassLoader] = None, bindings: Seq[(String, Any)] = Nil): Unit =
|
||||||
{
|
{
|
||||||
val arguments = new CompilerArguments(scalaInstance, cp)
|
val arguments = new CompilerArguments(scalaInstance, cp)
|
||||||
val classpathString = CompilerArguments.absString(arguments.finishClasspath(classpath ++ jlineJar))
|
val classpathString = CompilerArguments.absString(arguments.finishClasspath(classpath))
|
||||||
val bootClasspath = if(cp.autoBoot) arguments.createBootClasspath else ""
|
val bootClasspath = if(cp.autoBoot) arguments.createBootClasspath else ""
|
||||||
val (names, values) = bindings.unzip
|
val (names, values) = bindings.unzip
|
||||||
call("xsbt.ConsoleInterface", log)(
|
call("xsbt.ConsoleInterface", log)(
|
||||||
|
|
@ -80,7 +80,4 @@ class AnalyzingCompiler(val scalaInstance: ScalaInstance, val manager: Component
|
||||||
new classpath.DualLoader(scalaLoader, notXsbtiFilter, x => true, sbtLoader, xsbtiFilter, x => false)
|
new classpath.DualLoader(scalaLoader, notXsbtiFilter, x => true, sbtLoader, xsbtiFilter, x => false)
|
||||||
}
|
}
|
||||||
override def toString = "Analyzing compiler (Scala " + scalaInstance.actualVersion + ")"
|
override def toString = "Analyzing compiler (Scala " + scalaInstance.actualVersion + ")"
|
||||||
lazy val jlineJar =
|
|
||||||
try { IO.classLocationFile[jline.ConsoleReader] :: Nil }
|
|
||||||
catch { case e: Exception => Nil }
|
|
||||||
}
|
}
|
||||||
|
|
@ -56,8 +56,8 @@ object CompileTest extends Specification
|
||||||
private def isMissingRequirementError(t: Throwable) = t.getClass.getName == "scala.tools.nsc.MissingRequirementError"
|
private def isMissingRequirementError(t: Throwable) = t.getClass.getName == "scala.tools.nsc.MissingRequirementError"
|
||||||
private def testClasspath(scalaVersion: String) =
|
private def testClasspath(scalaVersion: String) =
|
||||||
WithCompiler.launcher { (launch, log) =>
|
WithCompiler.launcher { (launch, log) =>
|
||||||
def compiler(autoBoot: Boolean, compilerOnClasspath: Boolean): RawCompiler =
|
def compiler(bootLibrary: Boolean, compilerOnClasspath: Boolean): RawCompiler =
|
||||||
new RawCompiler(ScalaInstance(scalaVersion, launch), new ClasspathOptions(autoBoot, compilerOnClasspath, true), log)
|
new RawCompiler(ScalaInstance(scalaVersion, launch), new ClasspathOptions(bootLibrary, compilerOnClasspath, true, true), log)
|
||||||
|
|
||||||
val callback = new xsbti.TestCallback
|
val callback = new xsbti.TestCallback
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ package sbt
|
||||||
import sbt.complete.Parser
|
import sbt.complete.Parser
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import Parser._
|
import Parser._
|
||||||
|
import collection.mutable
|
||||||
|
|
||||||
sealed trait Aggregation
|
sealed trait Aggregation
|
||||||
final object Aggregation
|
final object Aggregation
|
||||||
|
|
@ -24,16 +25,19 @@ final object Aggregation
|
||||||
|
|
||||||
final case class KeyValue[+T](key: ScopedKey[_], value: T)
|
final case class KeyValue[+T](key: ScopedKey[_], value: T)
|
||||||
def getTasks[T](key: ScopedKey[T], structure: BuildStructure, transitive: Boolean): Seq[KeyValue[T]] =
|
def getTasks[T](key: ScopedKey[T], structure: BuildStructure, transitive: Boolean): Seq[KeyValue[T]] =
|
||||||
{
|
getTasks0(key, structure, transitive, new mutable.HashMap[(ScopedKey[_], Boolean), Seq[KeyValue[T]]])
|
||||||
val task = structure.data.get(key.scope, key.key).toList.map(t => KeyValue(key,t))
|
private type Memo[T] = mutable.Map[(ScopedKey[_], Boolean), Seq[KeyValue[T]]]
|
||||||
if(transitive) aggregateDeps(key, structure) ++ task else task
|
private[this] def getTasks0[T](key: ScopedKey[T], structure: BuildStructure, transitive: Boolean, memo: Memo[T]): Seq[KeyValue[T]] =
|
||||||
}
|
memo.getOrElseUpdate( (key, transitive), {
|
||||||
|
val task = structure.data.get(key.scope, key.key).toList.map(t => KeyValue(key,t))
|
||||||
|
if(transitive) aggregateDeps(key, structure, memo) ++ task else task
|
||||||
|
})
|
||||||
def projectAggregate(key: ScopedKey[_], structure: BuildStructure): Seq[ProjectRef] =
|
def projectAggregate(key: ScopedKey[_], structure: BuildStructure): Seq[ProjectRef] =
|
||||||
{
|
{
|
||||||
val project = key.scope.project.toOption.flatMap { ref => Project.getProjectForReference(ref, structure) }
|
val project = key.scope.project.toOption.flatMap { ref => Project.getProjectForReference(ref, structure) }
|
||||||
project match { case Some(p) => p.aggregate; case None => Nil }
|
project match { case Some(p) => p.aggregate; case None => Nil }
|
||||||
}
|
}
|
||||||
def aggregateDeps[T](key: ScopedKey[T], structure: BuildStructure): Seq[KeyValue[T]] =
|
private[this] def aggregateDeps[T](key: ScopedKey[T], structure: BuildStructure, memo: Memo[T]): Seq[KeyValue[T]] =
|
||||||
{
|
{
|
||||||
val aggregated = aggregate in Scope.fillTaskAxis(key.scope, key.key) get structure.data getOrElse Enabled
|
val aggregated = aggregate in Scope.fillTaskAxis(key.scope, key.key) get structure.data getOrElse Enabled
|
||||||
val (agg, transitive) =
|
val (agg, transitive) =
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ object Task
|
||||||
val uniformIn = tasks
|
val uniformIn = tasks
|
||||||
def work(mixed: Results[HNil], uniform: Seq[Result[Uniform]]) = {
|
def work(mixed: Results[HNil], uniform: Seq[Result[Uniform]]) = {
|
||||||
val inc = failures(uniform)
|
val inc = failures(uniform)
|
||||||
if(inc.isEmpty) f(uniform) else throw Incomplete(causes = inc)
|
if(inc.isEmpty) f(uniform) else throw Incomplete(None, causes = inc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def toNode[T, In <: HList](in: Tasks[In], f: Results[In] => Either[Task[T], T]): Node[Task, T] = new Node[Task, T] {
|
def toNode[T, In <: HList](in: Tasks[In], f: Results[In] => Either[Task[T], T]): Node[Task, T] = new Node[Task, T] {
|
||||||
|
|
@ -125,12 +125,12 @@ object Task
|
||||||
def allM[In <: HList]: Results[In] => In = in =>
|
def allM[In <: HList]: Results[In] => In = in =>
|
||||||
{
|
{
|
||||||
val incs = failuresM(in)
|
val incs = failuresM(in)
|
||||||
if(incs.isEmpty) in.down(Result.tryValue) else throw Incomplete(causes = incs)
|
if(incs.isEmpty) in.down(Result.tryValue) else throw Incomplete(None, causes = incs)
|
||||||
}
|
}
|
||||||
def all[D]: Seq[Result[D]] => Seq[D] = in =>
|
def all[D]: Seq[Result[D]] => Seq[D] = in =>
|
||||||
{
|
{
|
||||||
val incs = failures(in)
|
val incs = failures(in)
|
||||||
if(incs.isEmpty) in.map(Result.tryValue.apply[D]) else throw Incomplete(causes = incs)
|
if(incs.isEmpty) in.map(Result.tryValue.apply[D]) else throw Incomplete(None, causes = incs)
|
||||||
}
|
}
|
||||||
def failuresM[In <: HList]: Results[In] => Seq[Incomplete] = x => failures[Any](x.toList)
|
def failuresM[In <: HList]: Results[In] => Seq[Incomplete] = x => failures[Any](x.toList)
|
||||||
def failures[A]: Seq[Result[A]] => Seq[Incomplete] = _.collect { case Inc(i) => i }
|
def failures[A]: Seq[Result[A]] => Seq[Incomplete] = _.collect { case Inc(i) => i }
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ object Test
|
||||||
case Value(aa) :^: Value(bb) :^: Value(cc) :^: KNil => aa + " " + bb + " " + cc
|
case Value(aa) :^: Value(bb) :^: Value(cc) :^: KNil => aa + " " + bb + " " + cc
|
||||||
case x =>
|
case x =>
|
||||||
val cs = x.toList.collect { case Inc(x) => x } // workaround for double definition bug
|
val cs = x.toList.collect { case Inc(x) => x } // workaround for double definition bug
|
||||||
throw Incomplete(causes = cs)
|
throw Incomplete(None, causes = cs)
|
||||||
}
|
}
|
||||||
val d2 = i32 mapR f
|
val d2 = i32 mapR f
|
||||||
val f2: Values => Task[Any] = {
|
val f2: Values => Task[Any] = {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ object checkResult
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
case i: Incomplete =>
|
case i: Incomplete =>
|
||||||
println(Incomplete.show(i, true))
|
println(i)
|
||||||
"One or more tasks failed" |: false
|
"One or more tasks failed" |: false
|
||||||
case e =>
|
case e =>
|
||||||
e.printStackTrace
|
e.printStackTrace
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue