Add compile_multilib properties to all native prebuilts.

There was a special case in cc_prebuilt_binary only, which resulted in
prebuilt libraries getting both 32 and 64 bit variants even when their
sources only had one of them, and the other variant would be defunct
since it wouldn't get any prebuilt artefact.

This moves the handling of compile_multilib completely to the common
update code, so that SDK members don't need to deal with it. It doesn't
take SDK member defaults into account, which means a bit more
boilerplate in the snapshots, but it's simpler and less error prone
(different SDK member types have different defaults).

Bug: 151303681
Test: m nothing
Test: build/soong/scripts/build-aml-prebuilts.sh art-module-host-exports
  Check that the generated Android.bp passes Soong.
Change-Id: Ib73444c6788ee1c78480bdb103aa2b8ae8f2c63c
This commit is contained in:
Martin Stjernholm 2020-07-10 00:14:03 +01:00
parent 235e2fdbd3
commit 1e9c2677fd
4 changed files with 122 additions and 16 deletions

View File

@ -466,8 +466,7 @@ func RegisterSdkMemberType(memberType SdkMemberType) {
// Base structure for all implementations of SdkMemberProperties.
//
// Contains common properties that apply across many different member types. These
// are not affected by the optimization to extract common values.
// Contains common properties that apply across many different member types.
type SdkMemberPropertiesBase struct {
// The number of unique os types supported by the member variants.
//
@ -489,9 +488,7 @@ type SdkMemberPropertiesBase struct {
Os OsType `sdk:"keep"`
// The setting to use for the compile_multilib property.
//
// This property is set after optimization so there is no point in trying to optimize it.
Compile_multilib string `sdk:"keep"`
Compile_multilib string `android:"arch_variant"`
}
// The os prefix to use for any file paths in the sdk.

View File

@ -140,10 +140,6 @@ func (p *nativeBinaryInfoProperties) PopulateFromVariant(ctx android.SdkMemberCo
}
func (p *nativeBinaryInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
if p.Compile_multilib != "" {
propertySet.AddProperty("compile_multilib", p.Compile_multilib)
}
builder := ctx.SnapshotBuilder()
if p.outputFile != nil {
propertySet.AddProperty("srcs", []string{nativeBinaryPathFor(*p)})

View File

@ -73,12 +73,16 @@ func TestSdkCompileMultilibOverride(t *testing.T) {
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
device_supported: false,
host_supported: true,
native_shared_libs: ["sdkmember"],
compile_multilib: "64",
}
cc_library_shared {
name: "sdkmember",
device_supported: false,
host_supported: true,
srcs: ["Test.cpp"],
stl: "none",
compile_multilib: "64",
@ -86,8 +90,52 @@ func TestSdkCompileMultilibOverride(t *testing.T) {
`)
result.CheckSnapshot("mysdk", "",
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
name: "mysdk_sdkmember@current",
sdk_member_name: "sdkmember",
device_supported: false,
host_supported: true,
installable: false,
stl: "none",
compile_multilib: "64",
arch: {
x86_64: {
srcs: ["x86_64/lib/sdkmember.so"],
},
},
}
cc_prebuilt_library_shared {
name: "sdkmember",
prefer: false,
device_supported: false,
host_supported: true,
stl: "none",
compile_multilib: "64",
arch: {
x86_64: {
srcs: ["x86_64/lib/sdkmember.so"],
},
},
}
sdk_snapshot {
name: "mysdk@current",
device_supported: false,
host_supported: true,
native_shared_libs: ["mysdk_sdkmember@current"],
target: {
linux_glibc: {
compile_multilib: "64",
},
},
}
`),
checkAllCopyRules(`
.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> arm64/lib/sdkmember.so
.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> x86_64/lib/sdkmember.so
`))
}
@ -271,6 +319,7 @@ cc_prebuilt_object {
name: "mysdk_crtobj@current",
sdk_member_name: "crtobj",
stl: "none",
compile_multilib: "both",
arch: {
arm64: {
srcs: ["arm64/lib/crtobj.o"],
@ -285,6 +334,7 @@ cc_prebuilt_object {
name: "crtobj",
prefer: false,
stl: "none",
compile_multilib: "both",
arch: {
arm64: {
srcs: ["arm64/lib/crtobj.o"],
@ -378,6 +428,7 @@ cc_prebuilt_library_shared {
sdk_member_name: "mynativelib",
installable: false,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
arm64: {
@ -394,6 +445,7 @@ cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
arm64: {
@ -627,9 +679,9 @@ cc_prebuilt_binary {
host_supported: true,
installable: false,
stl: "none",
compile_multilib: "both",
static_executable: true,
nocrt: true,
compile_multilib: "both",
arch: {
x86_64: {
srcs: ["x86_64/bin/linker"],
@ -646,9 +698,9 @@ cc_prebuilt_binary {
device_supported: false,
host_supported: true,
stl: "none",
compile_multilib: "both",
static_executable: true,
nocrt: true,
compile_multilib: "both",
arch: {
x86_64: {
srcs: ["x86_64/bin/linker"],
@ -708,6 +760,7 @@ cc_prebuilt_library_shared {
],
installable: false,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
arm64: {
@ -729,6 +782,7 @@ cc_prebuilt_library_shared {
"apex2",
],
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
arm64: {
@ -830,6 +884,7 @@ cc_prebuilt_library_shared {
sdk_member_name: "mynativelib",
installable: false,
stl: "none",
compile_multilib: "both",
shared_libs: [
"mysdk_myothernativelib@current",
"libc",
@ -848,6 +903,7 @@ cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
stl: "none",
compile_multilib: "both",
shared_libs: [
"myothernativelib",
"libc",
@ -867,6 +923,7 @@ cc_prebuilt_library_shared {
sdk_member_name: "myothernativelib",
installable: false,
stl: "none",
compile_multilib: "both",
system_shared_libs: ["libm"],
arch: {
arm64: {
@ -882,6 +939,7 @@ cc_prebuilt_library_shared {
name: "myothernativelib",
prefer: false,
stl: "none",
compile_multilib: "both",
system_shared_libs: ["libm"],
arch: {
arm64: {
@ -898,6 +956,7 @@ cc_prebuilt_library_shared {
sdk_member_name: "mysystemnativelib",
installable: false,
stl: "none",
compile_multilib: "both",
arch: {
arm64: {
srcs: ["arm64/lib/mysystemnativelib.so"],
@ -912,6 +971,7 @@ cc_prebuilt_library_shared {
name: "mysystemnativelib",
prefer: false,
stl: "none",
compile_multilib: "both",
arch: {
arm64: {
srcs: ["arm64/lib/mysystemnativelib.so"],
@ -983,6 +1043,7 @@ cc_prebuilt_library_shared {
installable: false,
sdk_version: "minimum",
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
x86_64: {
@ -1003,6 +1064,7 @@ cc_prebuilt_library_shared {
host_supported: true,
sdk_version: "minimum",
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
x86_64: {
@ -1082,12 +1144,18 @@ cc_prebuilt_library_shared {
installable: false,
stl: "none",
target: {
linux_glibc: {
compile_multilib: "both",
},
linux_glibc_x86_64: {
srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
},
linux_glibc_x86: {
srcs: ["linux_glibc/x86/lib/mynativelib.so"],
},
windows: {
compile_multilib: "64",
},
windows_x86_64: {
srcs: ["windows/x86_64/lib/mynativelib.dll"],
},
@ -1101,12 +1169,18 @@ cc_prebuilt_library_shared {
host_supported: true,
stl: "none",
target: {
linux_glibc: {
compile_multilib: "both",
},
linux_glibc_x86_64: {
srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
},
linux_glibc_x86: {
srcs: ["linux_glibc/x86/lib/mynativelib.so"],
},
windows: {
compile_multilib: "64",
},
windows_x86_64: {
srcs: ["windows/x86_64/lib/mynativelib.dll"],
},
@ -1163,6 +1237,7 @@ cc_prebuilt_library_static {
sdk_member_name: "mynativelib",
installable: false,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
arm64: {
@ -1180,6 +1255,7 @@ cc_prebuilt_library_static {
name: "mynativelib",
prefer: false,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
arm64: {
@ -1251,6 +1327,7 @@ cc_prebuilt_library_static {
host_supported: true,
installable: false,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
x86_64: {
@ -1270,6 +1347,7 @@ cc_prebuilt_library_static {
device_supported: false,
host_supported: true,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
x86_64: {
@ -1330,6 +1408,7 @@ cc_prebuilt_library {
sdk_member_name: "mynativelib",
installable: false,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
arm64: {
@ -1355,6 +1434,7 @@ cc_prebuilt_library {
name: "mynativelib",
prefer: false,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
arm64: {
@ -1434,6 +1514,7 @@ cc_prebuilt_library_static {
host_supported: true,
installable: false,
stl: "none",
compile_multilib: "64",
export_include_dirs: ["include/include"],
arch: {
x86_64: {
@ -1449,6 +1530,7 @@ cc_prebuilt_library_static {
device_supported: false,
host_supported: true,
stl: "none",
compile_multilib: "64",
export_include_dirs: ["include/include"],
arch: {
x86_64: {
@ -1501,6 +1583,7 @@ cc_prebuilt_library_headers {
name: "mysdk_mynativeheaders@current",
sdk_member_name: "mynativeheaders",
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
}
@ -1508,6 +1591,7 @@ cc_prebuilt_library_headers {
name: "mynativeheaders",
prefer: false,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
}
@ -1553,6 +1637,7 @@ cc_prebuilt_library_headers {
device_supported: false,
host_supported: true,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
}
@ -1562,6 +1647,7 @@ cc_prebuilt_library_headers {
device_supported: false,
host_supported: true,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
}
@ -1614,6 +1700,7 @@ cc_prebuilt_library_headers {
sdk_member_name: "mynativeheaders",
host_supported: true,
stl: "none",
compile_multilib: "both",
export_system_include_dirs: ["common_os/include/include"],
target: {
android: {
@ -1630,6 +1717,7 @@ cc_prebuilt_library_headers {
prefer: false,
host_supported: true,
stl: "none",
compile_multilib: "both",
export_system_include_dirs: ["common_os/include/include"],
target: {
android: {
@ -1689,6 +1777,7 @@ cc_prebuilt_library_shared {
name: "mysdk_sslnil@current",
sdk_member_name: "sslnil",
installable: false,
compile_multilib: "both",
arch: {
arm64: {
srcs: ["arm64/lib/sslnil.so"],
@ -1702,6 +1791,7 @@ cc_prebuilt_library_shared {
cc_prebuilt_library_shared {
name: "sslnil",
prefer: false,
compile_multilib: "both",
arch: {
arm64: {
srcs: ["arm64/lib/sslnil.so"],
@ -1716,6 +1806,7 @@ cc_prebuilt_library_shared {
name: "mysdk_sslempty@current",
sdk_member_name: "sslempty",
installable: false,
compile_multilib: "both",
system_shared_libs: [],
arch: {
arm64: {
@ -1730,6 +1821,7 @@ cc_prebuilt_library_shared {
cc_prebuilt_library_shared {
name: "sslempty",
prefer: false,
compile_multilib: "both",
system_shared_libs: [],
arch: {
arm64: {
@ -1745,6 +1837,7 @@ cc_prebuilt_library_shared {
name: "mysdk_sslnonempty@current",
sdk_member_name: "sslnonempty",
installable: false,
compile_multilib: "both",
system_shared_libs: ["mysdk_sslnil@current"],
arch: {
arm64: {
@ -1759,6 +1852,7 @@ cc_prebuilt_library_shared {
cc_prebuilt_library_shared {
name: "sslnonempty",
prefer: false,
compile_multilib: "both",
system_shared_libs: ["sslnil"],
arch: {
arm64: {
@ -1807,6 +1901,7 @@ cc_prebuilt_library_shared {
sdk_member_name: "sslvariants",
host_supported: true,
installable: false,
compile_multilib: "both",
target: {
android: {
system_shared_libs: [],
@ -1830,6 +1925,7 @@ cc_prebuilt_library_shared {
name: "sslvariants",
prefer: false,
host_supported: true,
compile_multilib: "both",
target: {
android: {
system_shared_libs: [],
@ -1886,6 +1982,7 @@ cc_prebuilt_library_shared {
name: "mysdk_stubslib@current",
sdk_member_name: "stubslib",
installable: false,
compile_multilib: "both",
stubs: {
versions: ["3"],
},
@ -1902,6 +1999,7 @@ cc_prebuilt_library_shared {
cc_prebuilt_library_shared {
name: "stubslib",
prefer: false,
compile_multilib: "both",
stubs: {
versions: ["3"],
},
@ -1958,6 +2056,7 @@ cc_prebuilt_library_shared {
sdk_member_name: "stubslib",
host_supported: true,
installable: false,
compile_multilib: "both",
stubs: {
versions: ["3"],
},
@ -1981,6 +2080,7 @@ cc_prebuilt_library_shared {
name: "stubslib",
prefer: false,
host_supported: true,
compile_multilib: "both",
stubs: {
versions: ["3"],
},
@ -2036,6 +2136,7 @@ cc_prebuilt_library_shared {
host_supported: true,
installable: false,
unique_host_soname: true,
compile_multilib: "both",
target: {
android_arm64: {
srcs: ["android/arm64/lib/mylib.so"],
@ -2057,6 +2158,7 @@ cc_prebuilt_library_shared {
prefer: false,
host_supported: true,
unique_host_soname: true,
compile_multilib: "both",
target: {
android_arm64: {
srcs: ["android/arm64/lib/mylib.so"],

View File

@ -794,6 +794,17 @@ func (s *snapshotBuilder) isInternalMember(memberName string) bool {
return !ok
}
// Add the properties from the given SdkMemberProperties to the blueprint
// property set. This handles common properties in SdkMemberPropertiesBase and
// calls the member-specific AddToPropertySet for the rest.
func addSdkMemberPropertiesToSet(ctx *memberContext, memberProperties android.SdkMemberProperties, targetPropertySet android.BpPropertySet) {
if memberProperties.Base().Compile_multilib != "" {
targetPropertySet.AddProperty("compile_multilib", memberProperties.Base().Compile_multilib)
}
memberProperties.AddToPropertySet(ctx, targetPropertySet)
}
type sdkMemberRef struct {
memberType android.SdkMemberType
variant android.SdkAware
@ -1009,7 +1020,7 @@ func (osInfo *osTypeSpecificInfo) addToPropertySet(ctx *memberContext, bpModule
}
// Add the os specific but arch independent properties to the module.
osInfo.Properties.AddToPropertySet(ctx, osPropertySet)
addSdkMemberPropertiesToSet(ctx, osInfo.Properties, osPropertySet)
// Add arch (and possibly os) specific sections for each set of arch (and possibly
// os) specific properties.
@ -1111,11 +1122,11 @@ func (archInfo *archTypeSpecificInfo) optimizeProperties(ctx *memberContext, com
func (archInfo *archTypeSpecificInfo) addToPropertySet(ctx *memberContext, archPropertySet android.BpPropertySet, archOsPrefix string) {
archTypeName := archInfo.archType.Name
archTypePropertySet := archPropertySet.AddPropertySet(archOsPrefix + archTypeName)
archInfo.Properties.AddToPropertySet(ctx, archTypePropertySet)
addSdkMemberPropertiesToSet(ctx, archInfo.Properties, archTypePropertySet)
for _, linkInfo := range archInfo.linkInfos {
linkPropertySet := archTypePropertySet.AddPropertySet(linkInfo.linkType)
linkInfo.Properties.AddToPropertySet(ctx, linkPropertySet)
addSdkMemberPropertiesToSet(ctx, linkInfo.Properties, linkPropertySet)
}
}
@ -1221,7 +1232,7 @@ func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModu
extractCommonProperties(ctx.sdkMemberContext, commonValueExtractor, commonProperties, osSpecificPropertiesContainers)
// Add the common properties to the module.
commonProperties.AddToPropertySet(ctx, bpModule)
addSdkMemberPropertiesToSet(ctx, commonProperties, bpModule)
// Create a target property set into which target specific properties can be
// added.