Remove SdkMemberType.FinalizeModule

This was only being used to set the "stl" property for cc library sdk
member type and so that functionality was moved to AddPrebuiltModule()
and FinalizeModule was removed.

Required a few test changes to move the property to the correct
position in the generated module.

Bug: 142918168
Test: m nothing
Change-Id: If6400189833d4ff3285e7a7adf63a9b509e2a03b
This commit is contained in:
Paul Duffin 2020-03-11 18:42:08 +00:00
parent 438d379eb6
commit 0174d8d2c9
4 changed files with 28 additions and 44 deletions

View File

@ -356,15 +356,8 @@ type SdkMemberType interface {
// structure and calls AddToPropertySet(...) on the properties struct to add the member // structure and calls AddToPropertySet(...) on the properties struct to add the member
// specific properties in the correct place in the structure. // specific properties in the correct place in the structure.
// //
// * Finally, the FinalizeModule(...) method is called to add any additional properties.
// This was created to allow the property ordering in existing tests to be maintained so
// as to avoid having to change tests while refactoring.
//
AddPrebuiltModule(sdkModuleContext ModuleContext, builder SnapshotBuilder, member SdkMember) BpModule AddPrebuiltModule(sdkModuleContext ModuleContext, builder SnapshotBuilder, member SdkMember) BpModule
// Add any additional properties to the end of the module.
FinalizeModule(sdkModuleContext ModuleContext, builder SnapshotBuilder, member SdkMember, bpModule BpModule)
// Create a structure into which variant specific properties can be added. // Create a structure into which variant specific properties can be added.
CreateVariantPropertiesStruct() SdkMemberProperties CreateVariantPropertiesStruct() SdkMemberProperties
} }
@ -397,10 +390,6 @@ func (b *SdkMemberTypeBase) AddPrebuiltModule(sdkModuleContext ModuleContext, bu
return nil return nil
} }
func (b *SdkMemberTypeBase) FinalizeModule(sdkModuleContext ModuleContext, builder SnapshotBuilder, member SdkMember, module BpModule) {
// Do nothing by default
}
func (b *SdkMemberTypeBase) CreateVariantPropertiesStruct() SdkMemberProperties { func (b *SdkMemberTypeBase) CreateVariantPropertiesStruct() SdkMemberProperties {
panic("override me") panic("override me")
} }

View File

@ -105,15 +105,12 @@ func (mt *librarySdkMemberType) AddPrebuiltModule(sdkModuleContext android.Modul
if sdkVersion != "" { if sdkVersion != "" {
pbm.AddProperty("sdk_version", sdkVersion) pbm.AddProperty("sdk_version", sdkVersion)
} }
return pbm
}
func (mt *librarySdkMemberType) FinalizeModule(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember, bpModule android.BpModule) {
ccModule := (member.Variants()[0]).(*Module)
stl := ccModule.stl.Properties.Stl stl := ccModule.stl.Properties.Stl
if stl != nil { if stl != nil {
bpModule.AddProperty("stl", proptools.String(stl)) pbm.AddProperty("stl", proptools.String(stl))
} }
return pbm
} }
func (mt *librarySdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { func (mt *librarySdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {

View File

@ -298,6 +298,7 @@ cc_prebuilt_library_shared {
name: "mysdk_mynativelib@current", name: "mysdk_mynativelib@current",
sdk_member_name: "mynativelib", sdk_member_name: "mynativelib",
installable: false, installable: false,
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
arm64: { arm64: {
@ -308,12 +309,12 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mynativelib.so"], srcs: ["arm/lib/mynativelib.so"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "mynativelib", name: "mynativelib",
prefer: false, prefer: false,
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
arm64: { arm64: {
@ -324,7 +325,6 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mynativelib.so"], srcs: ["arm/lib/mynativelib.so"],
}, },
}, },
stl: "none",
} }
sdk_snapshot { sdk_snapshot {
@ -541,6 +541,7 @@ cc_prebuilt_library_shared {
"apex2", "apex2",
], ],
installable: false, installable: false,
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
arm64: { arm64: {
@ -552,7 +553,6 @@ cc_prebuilt_library_shared {
export_include_dirs: ["arm/include_gen/mynativelib"], export_include_dirs: ["arm/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
@ -562,6 +562,7 @@ cc_prebuilt_library_shared {
"apex1", "apex1",
"apex2", "apex2",
], ],
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
arm64: { arm64: {
@ -573,7 +574,6 @@ cc_prebuilt_library_shared {
export_include_dirs: ["arm/include_gen/mynativelib"], export_include_dirs: ["arm/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
sdk_snapshot { sdk_snapshot {
@ -665,6 +665,7 @@ cc_prebuilt_library_shared {
name: "mysdk_mynativelib@current", name: "mysdk_mynativelib@current",
sdk_member_name: "mynativelib", sdk_member_name: "mynativelib",
installable: false, installable: false,
stl: "none",
shared_libs: [ shared_libs: [
"mysdk_myothernativelib@current", "mysdk_myothernativelib@current",
"libc", "libc",
@ -677,12 +678,12 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mynativelib.so"], srcs: ["arm/lib/mynativelib.so"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "mynativelib", name: "mynativelib",
prefer: false, prefer: false,
stl: "none",
shared_libs: [ shared_libs: [
"myothernativelib", "myothernativelib",
"libc", "libc",
@ -695,13 +696,13 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mynativelib.so"], srcs: ["arm/lib/mynativelib.so"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "mysdk_myothernativelib@current", name: "mysdk_myothernativelib@current",
sdk_member_name: "myothernativelib", sdk_member_name: "myothernativelib",
installable: false, installable: false,
stl: "none",
system_shared_libs: ["libm"], system_shared_libs: ["libm"],
arch: { arch: {
arm64: { arm64: {
@ -711,12 +712,12 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/myothernativelib.so"], srcs: ["arm/lib/myothernativelib.so"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "myothernativelib", name: "myothernativelib",
prefer: false, prefer: false,
stl: "none",
system_shared_libs: ["libm"], system_shared_libs: ["libm"],
arch: { arch: {
arm64: { arm64: {
@ -726,13 +727,13 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/myothernativelib.so"], srcs: ["arm/lib/myothernativelib.so"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "mysdk_mysystemnativelib@current", name: "mysdk_mysystemnativelib@current",
sdk_member_name: "mysystemnativelib", sdk_member_name: "mysystemnativelib",
installable: false, installable: false,
stl: "none",
arch: { arch: {
arm64: { arm64: {
srcs: ["arm64/lib/mysystemnativelib.so"], srcs: ["arm64/lib/mysystemnativelib.so"],
@ -741,12 +742,12 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mysystemnativelib.so"], srcs: ["arm/lib/mysystemnativelib.so"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "mysystemnativelib", name: "mysystemnativelib",
prefer: false, prefer: false,
stl: "none",
arch: { arch: {
arm64: { arm64: {
srcs: ["arm64/lib/mysystemnativelib.so"], srcs: ["arm64/lib/mysystemnativelib.so"],
@ -755,7 +756,6 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mysystemnativelib.so"], srcs: ["arm/lib/mysystemnativelib.so"],
}, },
}, },
stl: "none",
} }
sdk_snapshot { sdk_snapshot {
@ -819,6 +819,7 @@ cc_prebuilt_library_shared {
host_supported: true, host_supported: true,
installable: false, installable: false,
sdk_version: "minimum", sdk_version: "minimum",
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
x86_64: { x86_64: {
@ -830,7 +831,6 @@ cc_prebuilt_library_shared {
export_include_dirs: ["x86/include_gen/mynativelib"], export_include_dirs: ["x86/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
@ -839,6 +839,7 @@ cc_prebuilt_library_shared {
device_supported: false, device_supported: false,
host_supported: true, host_supported: true,
sdk_version: "minimum", sdk_version: "minimum",
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
x86_64: { x86_64: {
@ -850,7 +851,6 @@ cc_prebuilt_library_shared {
export_include_dirs: ["x86/include_gen/mynativelib"], export_include_dirs: ["x86/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
sdk_snapshot { sdk_snapshot {
@ -918,6 +918,7 @@ cc_prebuilt_library_shared {
device_supported: false, device_supported: false,
host_supported: true, host_supported: true,
installable: false, installable: false,
stl: "none",
target: { target: {
linux_glibc_x86_64: { linux_glibc_x86_64: {
srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
@ -929,7 +930,6 @@ cc_prebuilt_library_shared {
srcs: ["windows/x86_64/lib/mynativelib.dll"], srcs: ["windows/x86_64/lib/mynativelib.dll"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
@ -937,6 +937,7 @@ cc_prebuilt_library_shared {
prefer: false, prefer: false,
device_supported: false, device_supported: false,
host_supported: true, host_supported: true,
stl: "none",
target: { target: {
linux_glibc_x86_64: { linux_glibc_x86_64: {
srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
@ -948,7 +949,6 @@ cc_prebuilt_library_shared {
srcs: ["windows/x86_64/lib/mynativelib.dll"], srcs: ["windows/x86_64/lib/mynativelib.dll"],
}, },
}, },
stl: "none",
} }
sdk_snapshot { sdk_snapshot {
@ -996,6 +996,7 @@ cc_prebuilt_library_static {
name: "myexports_mynativelib@current", name: "myexports_mynativelib@current",
sdk_member_name: "mynativelib", sdk_member_name: "mynativelib",
installable: false, installable: false,
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
arm64: { arm64: {
@ -1007,12 +1008,12 @@ cc_prebuilt_library_static {
export_include_dirs: ["arm/include_gen/mynativelib"], export_include_dirs: ["arm/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_static { cc_prebuilt_library_static {
name: "mynativelib", name: "mynativelib",
prefer: false, prefer: false,
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
arm64: { arm64: {
@ -1024,7 +1025,6 @@ cc_prebuilt_library_static {
export_include_dirs: ["arm/include_gen/mynativelib"], export_include_dirs: ["arm/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
module_exports_snapshot { module_exports_snapshot {
@ -1085,6 +1085,7 @@ cc_prebuilt_library_static {
device_supported: false, device_supported: false,
host_supported: true, host_supported: true,
installable: false, installable: false,
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
x86_64: { x86_64: {
@ -1096,7 +1097,6 @@ cc_prebuilt_library_static {
export_include_dirs: ["x86/include_gen/mynativelib"], export_include_dirs: ["x86/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_static { cc_prebuilt_library_static {
@ -1104,6 +1104,7 @@ cc_prebuilt_library_static {
prefer: false, prefer: false,
device_supported: false, device_supported: false,
host_supported: true, host_supported: true,
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
x86_64: { x86_64: {
@ -1115,7 +1116,6 @@ cc_prebuilt_library_static {
export_include_dirs: ["x86/include_gen/mynativelib"], export_include_dirs: ["x86/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
module_exports_snapshot { module_exports_snapshot {
@ -1183,6 +1183,7 @@ cc_prebuilt_library_static {
device_supported: false, device_supported: false,
host_supported: true, host_supported: true,
installable: false, installable: false,
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
x86_64: { x86_64: {
@ -1190,7 +1191,6 @@ cc_prebuilt_library_static {
export_include_dirs: ["x86_64/include_gen/mynativelib"], export_include_dirs: ["x86_64/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_static { cc_prebuilt_library_static {
@ -1198,6 +1198,7 @@ cc_prebuilt_library_static {
prefer: false, prefer: false,
device_supported: false, device_supported: false,
host_supported: true, host_supported: true,
stl: "none",
export_include_dirs: ["include/include"], export_include_dirs: ["include/include"],
arch: { arch: {
x86_64: { x86_64: {
@ -1205,7 +1206,6 @@ cc_prebuilt_library_static {
export_include_dirs: ["x86_64/include_gen/mynativelib"], export_include_dirs: ["x86_64/include_gen/mynativelib"],
}, },
}, },
stl: "none",
} }
module_exports_snapshot { module_exports_snapshot {
@ -1251,15 +1251,15 @@ func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
cc_prebuilt_library_headers { cc_prebuilt_library_headers {
name: "mysdk_mynativeheaders@current", name: "mysdk_mynativeheaders@current",
sdk_member_name: "mynativeheaders", sdk_member_name: "mynativeheaders",
export_include_dirs: ["include/include"],
stl: "none", stl: "none",
export_include_dirs: ["include/include"],
} }
cc_prebuilt_library_headers { cc_prebuilt_library_headers {
name: "mynativeheaders", name: "mynativeheaders",
prefer: false, prefer: false,
export_include_dirs: ["include/include"],
stl: "none", stl: "none",
export_include_dirs: ["include/include"],
} }
sdk_snapshot { sdk_snapshot {
@ -1304,8 +1304,8 @@ cc_prebuilt_library_headers {
sdk_member_name: "mynativeheaders", sdk_member_name: "mynativeheaders",
device_supported: false, device_supported: false,
host_supported: true, host_supported: true,
export_include_dirs: ["include/include"],
stl: "none", stl: "none",
export_include_dirs: ["include/include"],
} }
cc_prebuilt_library_headers { cc_prebuilt_library_headers {
@ -1313,8 +1313,8 @@ cc_prebuilt_library_headers {
prefer: false, prefer: false,
device_supported: false, device_supported: false,
host_supported: true, host_supported: true,
export_include_dirs: ["include/include"],
stl: "none", stl: "none",
export_include_dirs: ["include/include"],
} }
sdk_snapshot { sdk_snapshot {
@ -1366,6 +1366,7 @@ cc_prebuilt_library_headers {
name: "mysdk_mynativeheaders@current", name: "mysdk_mynativeheaders@current",
sdk_member_name: "mynativeheaders", sdk_member_name: "mynativeheaders",
host_supported: true, host_supported: true,
stl: "none",
export_system_include_dirs: ["include/include"], export_system_include_dirs: ["include/include"],
target: { target: {
android: { android: {
@ -1375,13 +1376,13 @@ cc_prebuilt_library_headers {
export_include_dirs: ["include/include-host"], export_include_dirs: ["include/include-host"],
}, },
}, },
stl: "none",
} }
cc_prebuilt_library_headers { cc_prebuilt_library_headers {
name: "mynativeheaders", name: "mynativeheaders",
prefer: false, prefer: false,
host_supported: true, host_supported: true,
stl: "none",
export_system_include_dirs: ["include/include"], export_system_include_dirs: ["include/include"],
target: { target: {
android: { android: {
@ -1391,7 +1392,6 @@ cc_prebuilt_library_headers {
export_include_dirs: ["include/include-host"], export_include_dirs: ["include/include-host"],
}, },
}, },
stl: "none",
} }
sdk_snapshot { sdk_snapshot {

View File

@ -976,8 +976,6 @@ func (s *sdk) createMemberSnapshot(sdkModuleContext android.ModuleContext, build
} }
} }
} }
memberType.FinalizeModule(sdkModuleContext, builder, member, bpModule)
} }
// Compute the list of possible os types that this sdk could support. // Compute the list of possible os types that this sdk could support.