diff options
Diffstat (limited to 'android/apex.go')
-rw-r--r-- | android/apex.go | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/android/apex.go b/android/apex.go index eabe05944..9bf6fc717 100644 --- a/android/apex.go +++ b/android/apex.go @@ -19,6 +19,8 @@ import ( "sort" "strconv" "sync" + + "github.com/google/blueprint" ) const ( @@ -32,6 +34,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 +59,8 @@ type ApexInfo struct { // respectively. type ApexModule interface { Module + DepIsInSameApex + apexModuleBase() *ApexModuleBase // Marks that this module should be built for the specified APEXes. @@ -88,16 +100,10 @@ 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 <= min_sdk_version. - // For example, with min_sdk_version is 10 and versionList is [9,11] - // it returns 9. - ChooseSdkVersion(versionList []string, useLatest bool) (string, error) - - ShouldSupportAndroid10() bool + // Returns the highest version which is <= maxSdkVersion. + // For example, with maxSdkVersion is 10 and versionList is [9,11] + // it returns 9 as string + ChooseSdkVersion(versionList []string, maxSdkVersion int) (string, error) } type ApexProperties struct { @@ -113,6 +119,15 @@ type ApexProperties struct { Info ApexInfo `blueprint:"mutated"` } +// Marker interface that identifies dependencies that are excluded from APEX +// contents. +type ExcludeFromApexContentsTag interface { + blueprint.DependencyTag + + // Method that differentiates this interface from others. + ExcludeFromApexContents() +} + // Provides default implementation for the ApexModule interface. APEX-aware // modules are expected to include this struct and call InitApexModule(). type ApexModuleBase struct { @@ -193,22 +208,14 @@ func (m *ApexModuleBase) DepIsInSameApex(ctx BaseModuleContext, dep Module) bool return true } -func (m *ApexModuleBase) ChooseSdkVersion(versionList []string, useLatest bool) (string, error) { - if useLatest { - return versionList[len(versionList)-1], nil - } - minSdkVersion := m.ApexProperties.Info.MinSdkVersion +func (m *ApexModuleBase) ChooseSdkVersion(versionList []string, maxSdkVersion int) (string, error) { for i := range versionList { ver, _ := strconv.Atoi(versionList[len(versionList)-i-1]) - if ver <= minSdkVersion { + if ver <= maxSdkVersion { return versionList[len(versionList)-i-1], nil } } - return "", fmt.Errorf("min_sdk_version is set %v, but not found in %v", minSdkVersion, versionList) -} - -func (m *ApexModuleBase) ShouldSupportAndroid10() bool { - return !m.IsForPlatform() && (m.ApexProperties.Info.MinSdkVersion <= SdkVersion_Android10) + return "", fmt.Errorf("not found a version(<=%d) in versionList: %v", maxSdkVersion, versionList) } func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) { |