Merge remote-tracking branch 'aosp/upstream' am: 726d2e6085
am: 8ea9686962
am: e9e15a5059
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/1354383 Change-Id: I3af91a8429100557dbb69cc54a5018b59c2d2280
This commit is contained in:
commit
d16010a154
2 changed files with 25 additions and 4 deletions
14
context.go
14
context.go
|
@ -2658,7 +2658,8 @@ func (c *Context) walkDeps(topModule *moduleInfo, allowDuplicates bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
type replace struct {
|
type replace struct {
|
||||||
from, to *moduleInfo
|
from, to *moduleInfo
|
||||||
|
predicate ReplaceDependencyPredicate
|
||||||
}
|
}
|
||||||
|
|
||||||
type rename struct {
|
type rename struct {
|
||||||
|
@ -2704,18 +2705,25 @@ func (c *Context) handleRenames(renames []rename) []error {
|
||||||
|
|
||||||
func (c *Context) handleReplacements(replacements []replace) []error {
|
func (c *Context) handleReplacements(replacements []replace) []error {
|
||||||
var errs []error
|
var errs []error
|
||||||
|
changedDeps := false
|
||||||
for _, replace := range replacements {
|
for _, replace := range replacements {
|
||||||
for _, m := range replace.from.reverseDeps {
|
for _, m := range replace.from.reverseDeps {
|
||||||
for i, d := range m.directDeps {
|
for i, d := range m.directDeps {
|
||||||
if d.module == replace.from {
|
if d.module == replace.from {
|
||||||
m.directDeps[i].module = replace.to
|
// If the replacement has a predicate then check it.
|
||||||
|
if replace.predicate == nil || replace.predicate(m.logicModule, d.tag, d.module.logicModule) {
|
||||||
|
m.directDeps[i].module = replace.to
|
||||||
|
changedDeps = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic.AddUint32(&c.depsModified, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if changedDeps {
|
||||||
|
atomic.AddUint32(&c.depsModified, 1)
|
||||||
|
}
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -843,6 +843,13 @@ type BottomUpMutatorContext interface {
|
||||||
// after the mutator pass is finished.
|
// after the mutator pass is finished.
|
||||||
ReplaceDependencies(string)
|
ReplaceDependencies(string)
|
||||||
|
|
||||||
|
// ReplaceDependencies replaces all dependencies on the identical variant of the module with the
|
||||||
|
// specified name with the current variant of this module as long as the supplied predicate returns
|
||||||
|
// true.
|
||||||
|
//
|
||||||
|
// Replacements don't take effect until after the mutator pass is finished.
|
||||||
|
ReplaceDependenciesIf(string, ReplaceDependencyPredicate)
|
||||||
|
|
||||||
// AliasVariation takes a variationName that was passed to CreateVariations for this module, and creates an
|
// AliasVariation takes a variationName that was passed to CreateVariations for this module, and creates an
|
||||||
// alias from the current variant to the new variant. The alias will be valid until the next time a mutator
|
// alias from the current variant to the new variant. The alias will be valid until the next time a mutator
|
||||||
// calls CreateVariations or CreateLocalVariations on this module without also calling AliasVariation. The
|
// calls CreateVariations or CreateLocalVariations on this module without also calling AliasVariation. The
|
||||||
|
@ -1006,6 +1013,12 @@ func (mctx *mutatorContext) AddInterVariantDependency(tag DependencyTag, from, t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mctx *mutatorContext) ReplaceDependencies(name string) {
|
func (mctx *mutatorContext) ReplaceDependencies(name string) {
|
||||||
|
mctx.ReplaceDependenciesIf(name, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReplaceDependencyPredicate func(from Module, tag DependencyTag, to Module) bool
|
||||||
|
|
||||||
|
func (mctx *mutatorContext) ReplaceDependenciesIf(name string, predicate ReplaceDependencyPredicate) {
|
||||||
target := mctx.context.moduleMatchingVariant(mctx.module, name)
|
target := mctx.context.moduleMatchingVariant(mctx.module, name)
|
||||||
|
|
||||||
if target == nil {
|
if target == nil {
|
||||||
|
@ -1013,7 +1026,7 @@ func (mctx *mutatorContext) ReplaceDependencies(name string) {
|
||||||
mctx.module.variantName, name))
|
mctx.module.variantName, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
mctx.replace = append(mctx.replace, replace{target, mctx.module})
|
mctx.replace = append(mctx.replace, replace{target, mctx.module, predicate})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mctx *mutatorContext) Rename(name string) {
|
func (mctx *mutatorContext) Rename(name string) {
|
||||||
|
|
Loading…
Reference in a new issue