From 7291095d82fee6937c867f324d9f7b6d14bb03b7 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Mon, 20 Jan 2020 18:16:30 +0000 Subject: 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 --- sdk/sdk.go | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'sdk/sdk.go') 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) -- cgit v1.2.3-59-g8ed1b