diff options
Diffstat (limited to 'android/apex.go')
-rw-r--r-- | android/apex.go | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/android/apex.go b/android/apex.go index 78511f9aa..db955b59c 100644 --- a/android/apex.go +++ b/android/apex.go @@ -149,15 +149,25 @@ var ApexBundleInfoProvider = blueprint.NewMutatorProvider[ApexBundleInfo]("apex_ // extracted from ApexModule to make it easier to define custom subsets of the ApexModule interface // and improve code navigation within the IDE. type DepIsInSameApex interface { - // DepIsInSameApex tests if the other module 'dep' is considered as part of the same APEX as - // this module. For example, a static lib dependency usually returns true here, while a + // OutgoingDepIsInSameApex tests if the module depended on via 'tag' is considered as part of + // the same APEX as this module. For example, a static lib dependency usually returns true here, while a // shared lib dependency to a stub library returns false. // // This method must not be called directly without first ignoring dependencies whose tags // implement ExcludeFromApexContentsTag. Calls from within the func passed to WalkPayloadDeps() // are fine as WalkPayloadDeps() will ignore those dependencies automatically. Otherwise, use // IsDepInSameApex instead. - DepIsInSameApex(ctx BaseModuleContext, dep Module) bool + OutgoingDepIsInSameApex(tag blueprint.DependencyTag) bool + + // IncomingDepIsInSameApex tests if this module depended on via 'tag' is considered as part of + // the same APEX as the depending module module. For example, a static lib dependency usually + // returns true here, while a shared lib dependency to a stub library returns false. + // + // This method must not be called directly without first ignoring dependencies whose tags + // implement ExcludeFromApexContentsTag. Calls from within the func passed to WalkPayloadDeps() + // are fine as WalkPayloadDeps() will ignore those dependencies automatically. Otherwise, use + // IsDepInSameApex instead. + IncomingDepIsInSameApex(tag blueprint.DependencyTag) bool } func IsDepInSameApex(ctx BaseModuleContext, module, dep Module) bool { @@ -167,7 +177,14 @@ func IsDepInSameApex(ctx BaseModuleContext, module, dep Module) bool { // apex as the parent. return false } - return module.(DepIsInSameApex).DepIsInSameApex(ctx, dep) + + if m, ok := module.(DepIsInSameApex); ok && !m.OutgoingDepIsInSameApex(depTag) { + return false + } + if d, ok := dep.(DepIsInSameApex); ok && !d.IncomingDepIsInSameApex(depTag) { + return false + } + return true } // ApexModule is the interface that a module type is expected to implement if the module has to be @@ -385,7 +402,15 @@ func (m *ApexModuleBase) UniqueApexVariations() bool { } // Implements ApexModule -func (m *ApexModuleBase) DepIsInSameApex(ctx BaseModuleContext, dep Module) bool { +func (m *ApexModuleBase) OutgoingDepIsInSameApex(tag blueprint.DependencyTag) bool { + // By default, if there is a dependency from A to B, we try to include both in the same + // APEX, unless B is explicitly from outside of the APEX (i.e. a stubs lib). Thus, returning + // true. This is overridden by some module types like apex.ApexBundle, cc.Module, + // java.Module, etc. + return true +} + +func (m *ApexModuleBase) IncomingDepIsInSameApex(tag blueprint.DependencyTag) bool { // By default, if there is a dependency from A to B, we try to include both in the same // APEX, unless B is explicitly from outside of the APEX (i.e. a stubs lib). Thus, returning // true. This is overridden by some module types like apex.ApexBundle, cc.Module, @@ -661,7 +686,7 @@ func ApexInfoMutator(ctx TopDownMutatorContext, module ApexModule) { // variant. func UpdateUniqueApexVariationsForDeps(mctx BottomUpMutatorContext, am ApexModule) { // anyInSameApex returns true if the two ApexInfo lists contain any values in an - // InApexVariants list in common. It is used instead of DepIsInSameApex because it needs to + // InApexVariants list in common. It is used instead of OutgoingDepIsInSameApex because it needs to // determine if the dep is in the same APEX due to being directly included, not only if it // is included _because_ it is a dependency. anyInSameApex := func(a, b ApexModule) bool { @@ -813,7 +838,7 @@ func CheckMinSdkVersion(ctx ModuleContext, minSdkVersion ApiLevel, walk WalkPayl // dependencies. return false } - if am, ok := from.(DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { + if !IsDepInSameApex(ctx, from, to) { return false } if m, ok := to.(ModuleWithMinSdkVersionCheck); ok { |