Extract logic to gather deps added for <apex>:<module> pairs
Trades having to traverse a module's direct dependencies multiple times for reusable code. While at the minute the amount of duplicated code is small (checking a tag and appending to a list) follow up changes will modify the gatherApexModulePairDepsWithTag module to improve error reporting greatly increasing the benefit of deduping. The cost of traversing a module's direct dependencies is very small as there will be only a very few dependencies. Bug: 177892522 Test: m nothing Change-Id: I16389102abd8038e1bfa52b63f4153bdf92ff553
This commit is contained in:
@@ -73,6 +73,8 @@ func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyN
|
|||||||
// module. This adds dependencies onto the prebuilt and source modules with the specified name,
|
// module. This adds dependencies onto the prebuilt and source modules with the specified name,
|
||||||
// depending on which ones are available. Visiting must use isActiveModule to select the preferred
|
// depending on which ones are available. Visiting must use isActiveModule to select the preferred
|
||||||
// module when both source and prebuilt modules are available.
|
// module when both source and prebuilt modules are available.
|
||||||
|
//
|
||||||
|
// Use gatherApexModulePairDepsWithTag to retrieve the dependencies.
|
||||||
func addDependencyOntoApexModulePair(ctx android.BottomUpMutatorContext, apex string, name string, tag blueprint.DependencyTag) {
|
func addDependencyOntoApexModulePair(ctx android.BottomUpMutatorContext, apex string, name string, tag blueprint.DependencyTag) {
|
||||||
var variations []blueprint.Variation
|
var variations []blueprint.Variation
|
||||||
if apex != "platform" && apex != "system_ext" {
|
if apex != "platform" && apex != "system_ext" {
|
||||||
@@ -118,6 +120,19 @@ func reportMissingVariationDependency(ctx android.BottomUpMutatorContext, variat
|
|||||||
ctx.AddFarVariationDependencies(variations, nil, name)
|
ctx.AddFarVariationDependencies(variations, nil, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gatherApexModulePairDepsWithTag returns the list of dependencies with the supplied tag that was
|
||||||
|
// added by addDependencyOntoApexModulePair.
|
||||||
|
func gatherApexModulePairDepsWithTag(ctx android.BaseModuleContext, tag blueprint.DependencyTag) []android.Module {
|
||||||
|
var modules []android.Module
|
||||||
|
ctx.VisitDirectDepsIf(isActiveModule, func(module android.Module) {
|
||||||
|
t := ctx.OtherModuleDependencyTag(module)
|
||||||
|
if t == tag {
|
||||||
|
modules = append(modules, module)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return modules
|
||||||
|
}
|
||||||
|
|
||||||
// ApexVariantReference specifies a particular apex variant of a module.
|
// ApexVariantReference specifies a particular apex variant of a module.
|
||||||
type ApexVariantReference struct {
|
type ApexVariantReference struct {
|
||||||
// The name of the module apex variant, i.e. the apex containing the module variant.
|
// The name of the module apex variant, i.e. the apex containing the module variant.
|
||||||
|
@@ -152,14 +152,8 @@ func addDependenciesOntoBootImageModules(ctx android.BottomUpMutatorContext, mod
|
|||||||
func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
b.classpathFragmentBase().generateAndroidBuildActions(ctx)
|
b.classpathFragmentBase().generateAndroidBuildActions(ctx)
|
||||||
|
|
||||||
ctx.VisitDirectDepsIf(isActiveModule, func(module android.Module) {
|
b.configuredModules = gatherApexModulePairDepsWithTag(ctx, platformBootclasspathModuleDepTag)
|
||||||
tag := ctx.OtherModuleDependencyTag(module)
|
b.fragments = gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag)
|
||||||
if tag == platformBootclasspathModuleDepTag {
|
|
||||||
b.configuredModules = append(b.configuredModules, module)
|
|
||||||
} else if tag == bootclasspathFragmentDepTag {
|
|
||||||
b.fragments = append(b.fragments, module)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments)
|
b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user