From befa4b91d707dedb80c7b234ac2f06d5f42ec553 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 4 Mar 2020 14:22:45 +0000 Subject: [PATCH] Copy apex_available properties to snapshot modules Bug: 142935992 Test: m nothing Change-Id: I1cdaae5b4e13a89dc46541dacd34ef5a44735b6a --- android/apex.go | 4 ++++ sdk/cc_sdk_test.go | 9 +++++++++ sdk/update.go | 12 +++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/android/apex.go b/android/apex.go index 43a42df9b..026d685ae 100644 --- a/android/apex.go +++ b/android/apex.go @@ -116,6 +116,10 @@ func (m *ApexModuleBase) apexModuleBase() *ApexModuleBase { return m } +func (m *ApexModuleBase) ApexAvailable() []string { + return m.ApexProperties.Apex_available +} + func (m *ApexModuleBase) BuildForApexes(apexes []ApexInfo) { m.apexVariationsLock.Lock() defer m.apexVariationsLock.Unlock() diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go index 45b548ccb..a14890ef2 100644 --- a/sdk/cc_sdk_test.go +++ b/sdk/cc_sdk_test.go @@ -414,6 +414,7 @@ func TestSnapshotWithCcSharedLibrary(t *testing.T) { "Test.cpp", "aidl/foo/bar/Test.aidl", ], + apex_available: ["apex1", "apex2"], export_include_dirs: ["include"], aidl: { export_aidl_headers: true, @@ -430,6 +431,10 @@ func TestSnapshotWithCcSharedLibrary(t *testing.T) { cc_prebuilt_library_shared { name: "mysdk_mynativelib@current", sdk_member_name: "mynativelib", + apex_available: [ + "apex1", + "apex2", + ], export_include_dirs: ["include/include"], arch: { arm64: { @@ -448,6 +453,10 @@ cc_prebuilt_library_shared { cc_prebuilt_library_shared { name: "mynativelib", prefer: false, + apex_available: [ + "apex1", + "apex2", + ], export_include_dirs: ["include/include"], arch: { arm64: { diff --git a/sdk/update.go b/sdk/update.go index 087b8bc64..b3357778e 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -550,6 +550,8 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType m := s.bpFile.newModule(moduleType) m.AddProperty("name", name) + variant := member.Variants()[0] + if s.sdk.isInternalMember(name) { // An internal member is only referenced from the sdk snapshot which is in the // same package so can be marked as private. @@ -557,7 +559,7 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType } else { // Extract visibility information from a member variant. All variants have the same // visibility so it doesn't matter which one is used. - visibility := android.EffectiveVisibilityRules(s.ctx, member.Variants()[0]) + visibility := android.EffectiveVisibilityRules(s.ctx, variant) if len(visibility) != 0 { m.AddProperty("visibility", visibility) } @@ -565,6 +567,14 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType addHostDeviceSupportedProperties(&s.sdk.ModuleBase, m) + // Where available copy apex_available properties from the member. + if apexAware, ok := variant.(interface{ ApexAvailable() []string }); ok { + apexAvailable := apexAware.ApexAvailable() + if len(apexAvailable) > 0 { + m.AddProperty("apex_available", apexAvailable) + } + } + s.prebuiltModules[name] = m s.prebuiltOrder = append(s.prebuiltOrder, m) return m