mirror of https://github.com/sbt/sbt.git
split load-time project structure scope resolution into two phases
first phase resolves referenced build URIs as each build is loaded second phase resolves references without an explicit project ID (this requires the whole structure to be known and this isn't available during the first phase) setting resolution is unchanged (done after both phases)
This commit is contained in:
parent
ba9c2c0e14
commit
d906455aed
|
|
@ -4,8 +4,6 @@
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import Types._
|
import Types._
|
||||||
import annotation.tailrec
|
|
||||||
import collection.mutable
|
|
||||||
|
|
||||||
sealed trait Settings[Scope]
|
sealed trait Settings[Scope]
|
||||||
{
|
{
|
||||||
|
|
@ -98,9 +96,12 @@ trait Init[Scope]
|
||||||
|
|
||||||
def delegate(sMap: ScopedMap)(implicit delegates: Scope => Seq[Scope]): ScopedMap =
|
def delegate(sMap: ScopedMap)(implicit delegates: Scope => Seq[Scope]): ScopedMap =
|
||||||
{
|
{
|
||||||
val md = memoDelegates(delegates)
|
def refMap(refKey: ScopedKey[_]) = new (ScopedKey ~> ScopedKey) { def apply[T](k: ScopedKey[T]) =
|
||||||
def refMap(refKey: ScopedKey[_]) = new (ScopedKey ~> ScopedKey) { def apply[T](k: ScopedKey[T]) = delegateForKey(sMap, k, md(k.scope), refKey) }
|
delegateForKey(sMap, k, delegates(k.scope), refKey)
|
||||||
val f = new (SettingSeq ~> SettingSeq) { def apply[T](ks: Seq[Setting[T]]) = ks.map{ s => s mapReferenced refMap(s.key) } }
|
}
|
||||||
|
val f = new (SettingSeq ~> SettingSeq) { def apply[T](ks: Seq[Setting[T]]) =
|
||||||
|
ks.map{ s => s mapReferenced refMap(s.key) }
|
||||||
|
}
|
||||||
sMap mapValues f
|
sMap mapValues f
|
||||||
}
|
}
|
||||||
private[this] def delegateForKey[T](sMap: ScopedMap, k: ScopedKey[T], scopes: Seq[Scope], refKey: ScopedKey[_]): ScopedKey[T] =
|
private[this] def delegateForKey[T](sMap: ScopedMap, k: ScopedKey[T], scopes: Seq[Scope], refKey: ScopedKey[_]): ScopedKey[T] =
|
||||||
|
|
@ -121,12 +122,6 @@ trait Init[Scope]
|
||||||
private[this] def applyInits(ordered: Seq[Compiled])(implicit delegates: Scope => Seq[Scope]): Settings[Scope] =
|
private[this] def applyInits(ordered: Seq[Compiled])(implicit delegates: Scope => Seq[Scope]): Settings[Scope] =
|
||||||
(empty /: ordered){ (m, comp) => comp.eval(m) }
|
(empty /: ordered){ (m, comp) => comp.eval(m) }
|
||||||
|
|
||||||
private[this] def memoDelegates(implicit delegates: Scope => Seq[Scope]): Scope => Seq[Scope] =
|
|
||||||
{
|
|
||||||
val dcache = new mutable.HashMap[Scope, Seq[Scope]]
|
|
||||||
(scope: Scope) => dcache.getOrElseUpdate(scope, delegates(scope))
|
|
||||||
}
|
|
||||||
|
|
||||||
private[this] def applySetting[T](map: Settings[Scope], setting: Setting[T]): Settings[Scope] =
|
private[this] def applySetting[T](map: Settings[Scope], setting: Setting[T]): Settings[Scope] =
|
||||||
{
|
{
|
||||||
def execK[HL <: HList, M[_]](a: KApply[HL, M, T]) =
|
def execK[HL <: HList, M[_]](a: KApply[HL, M, T]) =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue