diff --git a/android/apex.go b/android/apex.go index cbaf1c71a..d2fb6a107 100644 --- a/android/apex.go +++ b/android/apex.go @@ -32,6 +32,14 @@ type ApexInfo struct { 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 // 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). @@ -49,6 +57,8 @@ type ApexInfo struct { // respectively. type ApexModule interface { Module + DepIsInSameApex + apexModuleBase() *ApexModuleBase // 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" 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. // For example, with maxSdkVersion is 10 and versionList is [9,11] // it returns 9 as string diff --git a/android/sdk.go b/android/sdk.go index 78e88a0dd..2fdaf35aa 100644 --- a/android/sdk.go +++ b/android/sdk.go @@ -22,17 +22,30 @@ import ( "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 // built with SDK type SdkAware interface { Module + RequiredSdks + sdkBase() *SdkBase MakeMemberOf(sdk SdkRef) IsInAnySdk() bool ContainingSdk() SdkRef MemberName() string BuildWithSdks(sdks SdkRefs) - RequiredSdks() SdkRefs } // SdkRef refers to a version of an SDK diff --git a/apex/apex.go b/apex/apex.go index bb466129b..eb87ecf27 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -862,9 +862,7 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) { return } - cur := mctx.Module().(interface { - DepIsInSameApex(android.BaseModuleContext, android.Module) bool - }) + cur := mctx.Module().(android.DepIsInSameApex) mctx.VisitDirectDeps(func(child android.Module) { depName := mctx.OtherModuleName(child) diff --git a/sdk/sdk.go b/sdk/sdk.go index dabdf851e..a5709ac61 100644 --- a/sdk/sdk.go +++ b/sdk/sdk.go @@ -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 func sdkRequirementsMutator(mctx android.TopDownMutatorContext) { if m, ok := mctx.Module().(interface { - DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool - RequiredSdks() android.SdkRefs + android.DepIsInSameApex + android.RequiredSdks }); ok { requiredSdks := m.RequiredSdks() if len(requiredSdks) == 0 {