summaryrefslogtreecommitdiff
path: root/sdk/sdk.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2020-01-20 18:16:30 +0000
committer Paul Duffin <paulduffin@google.com> 2020-02-07 14:03:03 +0000
commit7291095d82fee6937c867f324d9f7b6d14bb03b7 (patch)
treed22b29c79ca9b5fb4b1f8d3fa47643a689ae1494 /sdk/sdk.go
parent7b81f5e9d76d1db684b0cf6691f04833c628c7e4 (diff)
Differentiate between exported and internal sdk members
Internal sdk members are used by an sdk member but not exported by the sdk. The exported sdk members are those listed explicitly in one of the sdk member list properties, e.g. java_header_libs. The prebuilts of an internal sdk member use a unique name so that they do not clash with the source module. The use of the module internally is an implementation detail that must not have any effect outside the snapshot. Having the same name as the source module could cause it to override the source module, hence why it needs a unique name. Similarly, they are marked as private so as to prevent their accidental use from outside the snapshot. Bug: 142940300 Test: m nothing Change-Id: Id5364b410be0592f65666afb3e40e9d3f020251c
Diffstat (limited to 'sdk/sdk.go')
-rw-r--r--sdk/sdk.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/sdk/sdk.go b/sdk/sdk.go
index f22763c10..dbe9ce223 100644
--- a/sdk/sdk.go
+++ b/sdk/sdk.go
@@ -50,6 +50,9 @@ type sdk struct {
// list properties, e.g. java_libs.
dynamicMemberTypeListProperties interface{}
+ // The set of exported members.
+ exportedMembers map[string]struct{}
+
properties sdkProperties
snapshotFile android.OptionalPath
@@ -217,6 +220,33 @@ func SnapshotModuleFactory() android.Module {
return s
}
+func (s *sdk) memberListProperties() []*sdkMemberListProperty {
+ return s.dynamicSdkMemberTypes.memberListProperties
+}
+
+func (s *sdk) getExportedMembers() map[string]struct{} {
+ if s.exportedMembers == nil {
+ // Collect all the exported members.
+ s.exportedMembers = make(map[string]struct{})
+
+ for _, memberListProperty := range s.memberListProperties() {
+ names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
+
+ // Every member specified explicitly in the properties is exported by the sdk.
+ for _, name := range names {
+ s.exportedMembers[name] = struct{}{}
+ }
+ }
+ }
+
+ return s.exportedMembers
+}
+
+func (s *sdk) isInternalMember(memberName string) bool {
+ _, ok := s.getExportedMembers()[memberName]
+ return !ok
+}
+
func (s *sdk) snapshot() bool {
return s.properties.Snapshot
}
@@ -290,7 +320,7 @@ func (t sdkMemberVersionedDepTag) ExcludeFromVisibilityEnforcement() {}
// Step 1: create dependencies from an SDK module to its members.
func memberMutator(mctx android.BottomUpMutatorContext) {
if s, ok := mctx.Module().(*sdk); ok {
- for _, memberListProperty := range s.dynamicSdkMemberTypes.memberListProperties {
+ for _, memberListProperty := range s.memberListProperties() {
names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
tag := memberListProperty.dependencyTag
memberListProperty.memberType.AddDependencies(mctx, tag, names)