diff options
author | 2021-04-23 21:20:20 +0100 | |
---|---|---|
committer | 2021-04-24 22:30:26 +0100 | |
commit | a720811c3813afb192ed69be0c38fac837514698 (patch) | |
tree | 34e4a3330b750650a397d574d28b54384adb1fe9 /android/sdk.go | |
parent | 2d1bb89fe3a5ce973dfd7154b36e03289280690c (diff) |
Allow exporting of sdk members to be done per tag
Previously, every module added to an sdk directly through one of the
SdkMemberType specific properties, e.g. java_libs, was exported and
every module added automatically via a transitive dependencies was not
exported. This change allows that behavior to be customized per tag.
Bug: 186290299
Test: m art-module-sdk
- verify that this change does not affect its contents.
Change-Id: I563b5bcd823e61c23cdb706cfcbb13337963d550
Diffstat (limited to 'android/sdk.go')
-rw-r--r-- | android/sdk.go | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/android/sdk.go b/android/sdk.go index f2cdc880b..b4ef8aa74 100644 --- a/android/sdk.go +++ b/android/sdk.go @@ -281,10 +281,31 @@ type SdkMember interface { Variants() []SdkAware } +// SdkMemberTypeDependencyTag is the interface that a tag must implement in order to allow the +// dependent module to be automatically added to the sdk. In order for this to work the +// SdkMemberType of the depending module must return true from +// SdkMemberType.HasTransitiveSdkMembers. type SdkMemberTypeDependencyTag interface { blueprint.DependencyTag + // SdkMemberType returns the SdkMemberType that will be used to automatically add the child module + // to the sdk. SdkMemberType() SdkMemberType + + // ExportMember determines whether a module added to the sdk through this tag will be exported + // from the sdk or not. + // + // An exported member is added to the sdk using its own name, e.g. if "foo" was exported from sdk + // "bar" then its prebuilt would be simply called "foo". A member can be added to the sdk via + // multiple tags and if any of those tags returns true from this method then the membe will be + // exported. Every module added directly to the sdk via one of the member type specific + // properties, e.g. java_libs, will automatically be exported. + // + // If a member is not exported then it is treated as an internal implementation detail of the + // sdk and so will be added with an sdk specific name. e.g. if "foo" was an internal member of sdk + // "bar" then its prebuilt would be called "bar_foo". Additionally its visibility will be set to + // "//visibility:private" so it will not be accessible from outside its Android.bp file. + ExportMember() bool } var _ SdkMemberTypeDependencyTag = (*sdkMemberDependencyTag)(nil) @@ -293,20 +314,28 @@ var _ ReplaceSourceWithPrebuilt = (*sdkMemberDependencyTag)(nil) type sdkMemberDependencyTag struct { blueprint.BaseDependencyTag memberType SdkMemberType + export bool } func (t *sdkMemberDependencyTag) SdkMemberType() SdkMemberType { return t.memberType } +func (t *sdkMemberDependencyTag) ExportMember() bool { + return t.export +} + // Prevent dependencies from the sdk/module_exports onto their members from being // replaced with a preferred prebuilt. func (t *sdkMemberDependencyTag) ReplaceSourceWithPrebuilt() bool { return false } -func DependencyTagForSdkMemberType(memberType SdkMemberType) SdkMemberTypeDependencyTag { - return &sdkMemberDependencyTag{memberType: memberType} +// DependencyTagForSdkMemberType creates an SdkMemberTypeDependencyTag that will cause any +// dependencies added by the tag to be added to the sdk as the specified SdkMemberType and exported +// (or not) as specified by the export parameter. +func DependencyTagForSdkMemberType(memberType SdkMemberType, export bool) SdkMemberTypeDependencyTag { + return &sdkMemberDependencyTag{memberType: memberType, export: export} } // Interface that must be implemented for every type that can be a member of an |