Merge "Extract DepIsInSameApex and RequiredSdks interfaces" am: 2010598a51

Change-Id: I2a32d1dcdfbf486d3f583665ce8b0608d599dc07
This commit is contained in:
Paul Duffin
2020-04-08 07:11:17 +00:00
committed by Automerger Merge Worker
4 changed files with 27 additions and 10 deletions

View File

@@ -32,6 +32,14 @@ type ApexInfo struct {
MinSdkVersion int MinSdkVersion int
} }
// 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 installed to the same
// APEX as this module
DepIsInSameApex(ctx BaseModuleContext, dep Module) bool
}
// ApexModule is the interface that a module type is expected to implement if // ApexModule is the interface that a module type is expected to implement if
// the module has to be built differently depending on whether the module // the module has to be built differently depending on whether the module
// is destined for an apex or not (installed to one of the regular partitions). // is destined for an apex or not (installed to one of the regular partitions).
@@ -49,6 +57,8 @@ type ApexInfo struct {
// respectively. // respectively.
type ApexModule interface { type ApexModule interface {
Module Module
DepIsInSameApex
apexModuleBase() *ApexModuleBase apexModuleBase() *ApexModuleBase
// Marks that this module should be built for the specified APEXes. // Marks that this module should be built for the specified APEXes.
@@ -88,10 +98,6 @@ type ApexModule interface {
// Tests if this module is available for the specified APEX or ":platform" // Tests if this module is available for the specified APEX or ":platform"
AvailableFor(what string) bool AvailableFor(what string) bool
// DepIsInSameApex tests if the other module 'dep' is installed to the same
// APEX as this module
DepIsInSameApex(ctx BaseModuleContext, dep Module) bool
// Returns the highest version which is <= maxSdkVersion. // Returns the highest version which is <= maxSdkVersion.
// For example, with maxSdkVersion is 10 and versionList is [9,11] // For example, with maxSdkVersion is 10 and versionList is [9,11]
// it returns 9 as string // it returns 9 as string

View File

@@ -22,17 +22,30 @@ import (
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
) )
// Extracted from SdkAware to make it easier to define custom subsets of the
// SdkAware interface and improve code navigation within the IDE.
//
// In addition to its use in SdkAware this interface must also be implemented by
// APEX to specify the SDKs required by that module and its contents. e.g. APEX
// is expected to implement RequiredSdks() by reading its own properties like
// `uses_sdks`.
type RequiredSdks interface {
// The set of SDKs required by an APEX and its contents.
RequiredSdks() SdkRefs
}
// SdkAware is the interface that must be supported by any module to become a member of SDK or to be // SdkAware is the interface that must be supported by any module to become a member of SDK or to be
// built with SDK // built with SDK
type SdkAware interface { type SdkAware interface {
Module Module
RequiredSdks
sdkBase() *SdkBase sdkBase() *SdkBase
MakeMemberOf(sdk SdkRef) MakeMemberOf(sdk SdkRef)
IsInAnySdk() bool IsInAnySdk() bool
ContainingSdk() SdkRef ContainingSdk() SdkRef
MemberName() string MemberName() string
BuildWithSdks(sdks SdkRefs) BuildWithSdks(sdks SdkRefs)
RequiredSdks() SdkRefs
} }
// SdkRef refers to a version of an SDK // SdkRef refers to a version of an SDK

View File

@@ -865,9 +865,7 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) {
return return
} }
cur := mctx.Module().(interface { cur := mctx.Module().(android.DepIsInSameApex)
DepIsInSameApex(android.BaseModuleContext, android.Module) bool
})
mctx.VisitDirectDeps(func(child android.Module) { mctx.VisitDirectDeps(func(child android.Module) {
depName := mctx.OtherModuleName(child) depName := mctx.OtherModuleName(child)

View File

@@ -434,8 +434,8 @@ func sdkDepsReplaceMutator(mctx android.BottomUpMutatorContext) {
// Step 6: ensure that the dependencies from outside of the APEX are all from the required SDKs // Step 6: ensure that the dependencies from outside of the APEX are all from the required SDKs
func sdkRequirementsMutator(mctx android.TopDownMutatorContext) { func sdkRequirementsMutator(mctx android.TopDownMutatorContext) {
if m, ok := mctx.Module().(interface { if m, ok := mctx.Module().(interface {
DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool android.DepIsInSameApex
RequiredSdks() android.SdkRefs android.RequiredSdks
}); ok { }); ok {
requiredSdks := m.RequiredSdks() requiredSdks := m.RequiredSdks()
if len(requiredSdks) == 0 { if len(requiredSdks) == 0 {