Pass SdkMember to AddPrebuiltModule instead of the name

This is needed for a follow up change that makes sure that the
prebuilt modules have the same visibility as the source modules.

Bug: 143678475
Test: m conscrypt-module-sdk
Change-Id: I9461c8c094ab19ee9ececb5e5fd50565789f2fa2
This commit is contained in:
Paul Duffin 2019-12-05 18:19:29 +00:00
parent 667039f404
commit 9d8d609fcd
5 changed files with 10 additions and 9 deletions

View File

@ -178,7 +178,7 @@ type SnapshotBuilder interface {
// prefer=true. And one that is not versioned, not marked as prefer=true and // prefer=true. And one that is not versioned, not marked as prefer=true and
// will only be used if the equivalently named non-prebuilt module is not // will only be used if the equivalently named non-prebuilt module is not
// present. // present.
AddPrebuiltModule(name string, moduleType string) BpModule AddPrebuiltModule(member SdkMember, moduleType string) BpModule
} }
// A set of properties for use in a .bp file. // A set of properties for use in a .bp file.

View File

@ -1435,10 +1435,10 @@ func (mt *librarySdkMemberType) IsInstance(module android.Module) bool {
// copy exported header files and stub *.so files // copy exported header files and stub *.so files
func (mt *librarySdkMemberType) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) { func (mt *librarySdkMemberType) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
info := organizeVariants(member) info := organizeVariants(member)
buildSharedNativeLibSnapshot(sdkModuleContext, info, builder) buildSharedNativeLibSnapshot(sdkModuleContext, info, builder, member)
} }
func buildSharedNativeLibSnapshot(sdkModuleContext android.ModuleContext, info *nativeLibInfo, builder android.SnapshotBuilder) { func buildSharedNativeLibSnapshot(sdkModuleContext android.ModuleContext, info *nativeLibInfo, builder android.SnapshotBuilder, member android.SdkMember) {
// a function for emitting include dirs // a function for emitting include dirs
printExportedDirCopyCommandsForNativeLibs := func(lib archSpecificNativeLibInfo) { printExportedDirCopyCommandsForNativeLibs := func(lib archSpecificNativeLibInfo) {
includeDirs := lib.exportedIncludeDirs includeDirs := lib.exportedIncludeDirs
@ -1489,10 +1489,10 @@ func buildSharedNativeLibSnapshot(sdkModuleContext android.ModuleContext, info *
} }
} }
info.generatePrebuiltLibrary(sdkModuleContext, builder) info.generatePrebuiltLibrary(sdkModuleContext, builder, member)
} }
func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder) { func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
// a function for emitting include dirs // a function for emitting include dirs
addExportedDirsForNativeLibs := func(lib archSpecificNativeLibInfo, properties android.BpPropertySet, systemInclude bool) { addExportedDirsForNativeLibs := func(lib archSpecificNativeLibInfo, properties android.BpPropertySet, systemInclude bool) {
@ -1509,7 +1509,7 @@ func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.Modu
properties.AddProperty(propertyName, includeDirs) properties.AddProperty(propertyName, includeDirs)
} }
pbm := builder.AddPrebuiltModule(info.name, "cc_prebuilt_library_shared") pbm := builder.AddPrebuiltModule(member, "cc_prebuilt_library_shared")
if !info.hasArchSpecificFlags { if !info.hasArchSpecificFlags {
addExportedDirsForNativeLibs(info.archVariants[0], pbm, false /*systemInclude*/) addExportedDirsForNativeLibs(info.archVariants[0], pbm, false /*systemInclude*/)

View File

@ -2000,6 +2000,6 @@ func (mt *droidStubsSdkMemberType) BuildSnapshot(sdkModuleContext android.Module
snapshotRelativeDir := filepath.Join("java", d.Name()+"_stubs_sources") snapshotRelativeDir := filepath.Join("java", d.Name()+"_stubs_sources")
builder.UnzipToSnapshot(stubsSrcJar, snapshotRelativeDir) builder.UnzipToSnapshot(stubsSrcJar, snapshotRelativeDir)
pbm := builder.AddPrebuiltModule(sdkModuleContext.OtherModuleName(d), "prebuilt_stubs_sources") pbm := builder.AddPrebuiltModule(member, "prebuilt_stubs_sources")
pbm.AddProperty("srcs", []string{snapshotRelativeDir}) pbm.AddProperty("srcs", []string{snapshotRelativeDir})
} }

View File

@ -1760,7 +1760,7 @@ func (mt *librarySdkMemberType) buildSnapshot(
} }
} }
module := builder.AddPrebuiltModule(sdkModuleContext.OtherModuleName(j), "java_import") module := builder.AddPrebuiltModule(member, "java_import")
module.AddProperty("jars", []string{snapshotRelativeJavaLibPath}) module.AddProperty("jars", []string{snapshotRelativeJavaLibPath})
} }

View File

@ -368,7 +368,8 @@ func (s *snapshotBuilder) UnzipToSnapshot(zipPath android.Path, destDir string)
s.zipsToMerge = append(s.zipsToMerge, tmpZipPath) s.zipsToMerge = append(s.zipsToMerge, tmpZipPath)
} }
func (s *snapshotBuilder) AddPrebuiltModule(name string, moduleType string) android.BpModule { func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType string) android.BpModule {
name := member.Name()
if s.prebuiltModules[name] != nil { if s.prebuiltModules[name] != nil {
panic(fmt.Sprintf("Duplicate module detected, module %s has already been added", name)) panic(fmt.Sprintf("Duplicate module detected, module %s has already been added", name))
} }