apexDepsMutator uses WalkDeps

apexDepsMutator marks all dependencies of apex modules. Previously, it
was converted from WalkDeps() to Top-down mutator to avoid the pitfall
of WalkDeps() bug. (It did't handle multiple visits via different
paths.)

Because WalkDeps() problem solved in aosp/1277516, apexDepsMutator can
be reverted to use WalkDeps().

Even though there's no observable difference between them, I revert this
for the up-coming change, which requires different pruning strategies
per apexes.

Bug: 159195575
Test: m
Change-Id: Ib09cbc7a3dfd143dd37b660b1aea6c71392ce2e3
This commit is contained in:
Jooyung Han
2020-07-22 15:17:19 +09:00
parent 9429c612ff
commit 698dd9f007
2 changed files with 36 additions and 44 deletions

View File

@@ -669,7 +669,7 @@ func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
}
func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
ctx.TopDown("apex_deps", apexDepsMutator)
ctx.TopDown("apex_deps", apexDepsMutator).Parallel()
ctx.BottomUp("apex", apexMutator).Parallel()
ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
@@ -682,33 +682,30 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) {
if !mctx.Module().Enabled() {
return
}
var apexBundles []android.ApexInfo
var directDep bool
if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
apexBundles = []android.ApexInfo{{
ApexName: mctx.ModuleName(),
MinSdkVersion: a.minSdkVersion(mctx),
Updatable: a.Updatable(),
}}
directDep = true
} else if am, ok := mctx.Module().(android.ApexModule); ok {
apexBundles = am.ApexVariations()
directDep = false
}
if len(apexBundles) == 0 {
a, ok := mctx.Module().(*apexBundle)
if !ok || a.vndkApex {
return
}
cur := mctx.Module().(android.DepIsInSameApex)
mctx.VisitDirectDeps(func(child android.Module) {
depName := mctx.OtherModuleName(child)
if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
(cur.DepIsInSameApex(mctx, child) || inAnySdk(child)) {
android.UpdateApexDependency(apexBundles, depName, directDep)
am.BuildForApexes(apexBundles)
apexInfo := android.ApexInfo{
ApexName: mctx.ModuleName(),
MinSdkVersion: a.minSdkVersion(mctx),
Updatable: a.Updatable(),
}
mctx.WalkDeps(func(child, parent android.Module) bool {
am, ok := child.(android.ApexModule)
if !ok || !am.CanHaveApexVariants() {
return false
}
if !parent.(android.DepIsInSameApex).DepIsInSameApex(mctx, child) && !inAnySdk(child) {
return false
}
depName := mctx.OtherModuleName(child)
// If the parent is apexBundle, this child is directly depended.
_, directDep := parent.(*apexBundle)
android.UpdateApexDependency(apexInfo, depName, directDep)
am.BuildForApex(apexInfo)
return true
})
}