Set compile_multilib for SDK snapshots for device.
Previously compile_multilib was ignored for device and defaulted to "both", which could lead to an internal inconsistency in the snapshot if a member was 32- or 64-only. This also implements common property optimisation for compile_multilib, by adding a struct that can be extended to other properties in the future. Test: m nothing Bug: 151303681 Change-Id: I3e96222858e5e755173aca03508a23c431977e2a
This commit is contained in:
parent
89238f4703
commit
4cfa2c692b
|
@ -73,7 +73,6 @@ func TestSdkCompileMultilibOverride(t *testing.T) {
|
||||||
result := testSdkWithCc(t, `
|
result := testSdkWithCc(t, `
|
||||||
sdk {
|
sdk {
|
||||||
name: "mysdk",
|
name: "mysdk",
|
||||||
device_supported: false,
|
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
native_shared_libs: ["sdkmember"],
|
native_shared_libs: ["sdkmember"],
|
||||||
compile_multilib: "64",
|
compile_multilib: "64",
|
||||||
|
@ -81,7 +80,6 @@ func TestSdkCompileMultilibOverride(t *testing.T) {
|
||||||
|
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
name: "sdkmember",
|
name: "sdkmember",
|
||||||
device_supported: false,
|
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
srcs: ["Test.cpp"],
|
srcs: ["Test.cpp"],
|
||||||
stl: "none",
|
stl: "none",
|
||||||
|
@ -96,14 +94,16 @@ func TestSdkCompileMultilibOverride(t *testing.T) {
|
||||||
cc_prebuilt_library_shared {
|
cc_prebuilt_library_shared {
|
||||||
name: "mysdk_sdkmember@current",
|
name: "mysdk_sdkmember@current",
|
||||||
sdk_member_name: "sdkmember",
|
sdk_member_name: "sdkmember",
|
||||||
device_supported: false,
|
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
installable: false,
|
installable: false,
|
||||||
stl: "none",
|
stl: "none",
|
||||||
compile_multilib: "64",
|
compile_multilib: "64",
|
||||||
arch: {
|
target: {
|
||||||
x86_64: {
|
android_arm64: {
|
||||||
srcs: ["x86_64/lib/sdkmember.so"],
|
srcs: ["android/arm64/lib/sdkmember.so"],
|
||||||
|
},
|
||||||
|
linux_glibc_x86_64: {
|
||||||
|
srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -111,31 +111,29 @@ cc_prebuilt_library_shared {
|
||||||
cc_prebuilt_library_shared {
|
cc_prebuilt_library_shared {
|
||||||
name: "sdkmember",
|
name: "sdkmember",
|
||||||
prefer: false,
|
prefer: false,
|
||||||
device_supported: false,
|
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
stl: "none",
|
stl: "none",
|
||||||
compile_multilib: "64",
|
compile_multilib: "64",
|
||||||
arch: {
|
target: {
|
||||||
x86_64: {
|
android_arm64: {
|
||||||
srcs: ["x86_64/lib/sdkmember.so"],
|
srcs: ["android/arm64/lib/sdkmember.so"],
|
||||||
|
},
|
||||||
|
linux_glibc_x86_64: {
|
||||||
|
srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
sdk_snapshot {
|
sdk_snapshot {
|
||||||
name: "mysdk@current",
|
name: "mysdk@current",
|
||||||
device_supported: false,
|
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
native_shared_libs: ["mysdk_sdkmember@current"],
|
native_shared_libs: ["mysdk_sdkmember@current"],
|
||||||
target: {
|
compile_multilib: "64",
|
||||||
linux_glibc: {
|
|
||||||
compile_multilib: "64",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
`),
|
`),
|
||||||
checkAllCopyRules(`
|
checkAllCopyRules(`
|
||||||
.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> x86_64/lib/sdkmember.so
|
.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
|
||||||
|
.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
|
||||||
`))
|
`))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1527,11 +1525,7 @@ module_exports_snapshot {
|
||||||
device_supported: false,
|
device_supported: false,
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
native_static_libs: ["myexports_mynativelib@current"],
|
native_static_libs: ["myexports_mynativelib@current"],
|
||||||
target: {
|
compile_multilib: "64",
|
||||||
linux_glibc: {
|
|
||||||
compile_multilib: "64",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}`),
|
}`),
|
||||||
checkAllCopyRules(`
|
checkAllCopyRules(`
|
||||||
include/Test.h -> include/include/Test.h
|
include/Test.h -> include/include/Test.h
|
||||||
|
|
|
@ -323,19 +323,37 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
|
||||||
// Add properties common to all os types.
|
// Add properties common to all os types.
|
||||||
s.addMemberPropertiesToPropertySet(builder, snapshotModule, commonDynamicMemberProperties)
|
s.addMemberPropertiesToPropertySet(builder, snapshotModule, commonDynamicMemberProperties)
|
||||||
|
|
||||||
|
// Optimize other per-variant properties, besides the dynamic member lists.
|
||||||
|
type variantProperties struct {
|
||||||
|
Compile_multilib string `android:"arch_variant"`
|
||||||
|
}
|
||||||
|
var variantPropertiesContainers []propertiesContainer
|
||||||
|
variantToProperties := make(map[*sdk]*variantProperties)
|
||||||
|
for _, sdkVariant := range sdkVariants {
|
||||||
|
props := &variantProperties{
|
||||||
|
Compile_multilib: sdkVariant.multilibUsages.String(),
|
||||||
|
}
|
||||||
|
variantPropertiesContainers = append(variantPropertiesContainers, &dynamicMemberPropertiesContainer{sdkVariant, props})
|
||||||
|
variantToProperties[sdkVariant] = props
|
||||||
|
}
|
||||||
|
commonVariantProperties := variantProperties{}
|
||||||
|
extractor = newCommonValueExtractor(commonVariantProperties)
|
||||||
|
extractCommonProperties(ctx, extractor, &commonVariantProperties, variantPropertiesContainers)
|
||||||
|
if commonVariantProperties.Compile_multilib != "" && commonVariantProperties.Compile_multilib != "both" {
|
||||||
|
// Compile_multilib defaults to both so only needs to be set when it's
|
||||||
|
// specified and not both.
|
||||||
|
snapshotModule.AddProperty("compile_multilib", commonVariantProperties.Compile_multilib)
|
||||||
|
}
|
||||||
|
|
||||||
// Iterate over the os types in a fixed order.
|
// Iterate over the os types in a fixed order.
|
||||||
targetPropertySet := snapshotModule.AddPropertySet("target")
|
targetPropertySet := snapshotModule.AddPropertySet("target")
|
||||||
for _, osType := range s.getPossibleOsTypes() {
|
for _, osType := range s.getPossibleOsTypes() {
|
||||||
if sdkVariant, ok := osTypeToMemberProperties[osType]; ok {
|
if sdkVariant, ok := osTypeToMemberProperties[osType]; ok {
|
||||||
osPropertySet := targetPropertySet.AddPropertySet(sdkVariant.Target().Os.Name)
|
osPropertySet := targetPropertySet.AddPropertySet(sdkVariant.Target().Os.Name)
|
||||||
|
|
||||||
// Compile_multilib defaults to both and must always be set to both on the
|
variantProps := variantToProperties[sdkVariant]
|
||||||
// device and so only needs to be set when targeted at the host and is neither
|
if variantProps.Compile_multilib != "" && variantProps.Compile_multilib != "both" {
|
||||||
// unspecified or both.
|
osPropertySet.AddProperty("compile_multilib", variantProps.Compile_multilib)
|
||||||
multilib := sdkVariant.multilibUsages
|
|
||||||
if (osType.Class == android.Host || osType.Class == android.HostCross) &&
|
|
||||||
multilib != multilibNone && multilib != multilibBoth {
|
|
||||||
osPropertySet.AddProperty("compile_multilib", multilib.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s.addMemberPropertiesToPropertySet(builder, osPropertySet, sdkVariant.dynamicMemberTypeListProperties)
|
s.addMemberPropertiesToPropertySet(builder, osPropertySet, sdkVariant.dynamicMemberTypeListProperties)
|
||||||
|
|
Loading…
Reference in New Issue