Merge "Default apex's compile_multilib to "first" in bp2build" am: 827db14152

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2243697

Change-Id: I6ffdf6e089443358751840e99981184ddd4d6a8c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Vinh Tran
2022-10-17 14:37:59 +00:00
committed by Automerger Merge Worker
3 changed files with 156 additions and 38 deletions

View File

@@ -3391,7 +3391,12 @@ func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (baze
Native_shared_libs_32: bazel.LabelListAttribute{},
Native_shared_libs_64: bazel.LabelListAttribute{},
}
compileMultilib := "both"
// https://cs.android.com/android/platform/superproject/+/master:build/soong/android/arch.go;l=698;drc=f05b0d35d2fbe51be9961ce8ce8031f840295c68
// https://cs.android.com/android/platform/superproject/+/master:build/soong/apex/apex.go;l=2549;drc=ec731a83e3e2d80a1254e32fd4ad7ef85e262669
// In Soong, decodeMultilib, used to get multilib, return "first" if defaultMultilib is set to "common".
// Since apex sets defaultMultilib to be "common", equivalent compileMultilib in bp2build for apex should be "first"
compileMultilib := "first"
if a.CompileMultilib() != nil {
compileMultilib = *a.CompileMultilib()
}

View File

@@ -4130,6 +4130,76 @@ func TestApexName(t *testing.T) {
ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n")
}
func TestCompileMultilibProp(t *testing.T) {
testCases := []struct {
compileMultiLibProp string
containedLibs []string
notContainedLibs []string
}{
{
containedLibs: []string{
"image.apex/lib64/mylib.so",
"image.apex/lib/mylib.so",
},
compileMultiLibProp: `compile_multilib: "both",`,
},
{
containedLibs: []string{"image.apex/lib64/mylib.so"},
notContainedLibs: []string{"image.apex/lib/mylib.so"},
compileMultiLibProp: `compile_multilib: "first",`,
},
{
containedLibs: []string{"image.apex/lib64/mylib.so"},
notContainedLibs: []string{"image.apex/lib/mylib.so"},
// compile_multilib, when unset, should result to the same output as when compile_multilib is "first"
},
{
containedLibs: []string{"image.apex/lib64/mylib.so"},
notContainedLibs: []string{"image.apex/lib/mylib.so"},
compileMultiLibProp: `compile_multilib: "64",`,
},
{
containedLibs: []string{"image.apex/lib/mylib.so"},
notContainedLibs: []string{"image.apex/lib64/mylib.so"},
compileMultiLibProp: `compile_multilib: "32",`,
},
}
for _, testCase := range testCases {
ctx := testApex(t, fmt.Sprintf(`
apex {
name: "myapex",
key: "myapex.key",
%s
native_shared_libs: ["mylib"],
updatable: false,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
cc_library {
name: "mylib",
srcs: ["mylib.cpp"],
apex_available: [
"//apex_available:platform",
"myapex",
],
}
`, testCase.compileMultiLibProp),
)
module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
for _, containedLib := range testCase.containedLibs {
ensureContains(t, copyCmds, containedLib)
}
for _, notContainedLib := range testCase.notContainedLibs {
ensureNotContains(t, copyCmds, notContainedLib)
}
}
}
func TestNonTestApex(t *testing.T) {
ctx := testApex(t, `
apex {