Add target_compatible_with for compile_multilib
For explicit values of compile_multilib (e.g. 32 or 64), add an incompatibilty constraint for the arches that do not have the correct bitness. Test: go test ./bp2build Bug: 299135307 Change-Id: I4cd997de6804a5c6d89086d740f773936db1cab9
This commit is contained in:
@@ -5279,3 +5279,58 @@ cc_library {
|
||||
}
|
||||
runCcLibraryTestCase(t, tc)
|
||||
}
|
||||
|
||||
func TestCcCompileMultilibConversion(t *testing.T) {
|
||||
tc := Bp2buildTestCase{
|
||||
Description: "cc_library with compile_multilib",
|
||||
ModuleTypeUnderTest: "cc_library",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
Blueprint: `
|
||||
cc_library {
|
||||
name: "lib32",
|
||||
compile_multilib: "32",
|
||||
}
|
||||
cc_library {
|
||||
name: "lib64",
|
||||
compile_multilib: "64",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("cc_library_shared", "lib32", AttrNameToString{
|
||||
"local_includes": `["."]`,
|
||||
"target_compatible_with": `["//build/bazel/platforms/os:android"] + select({
|
||||
"//build/bazel/platforms/arch:arm64": ["@platforms//:incompatible"],
|
||||
"//build/bazel/platforms/arch:riscv64": ["@platforms//:incompatible"],
|
||||
"//build/bazel/platforms/arch:x86_64": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
MakeBazelTargetNoRestrictions("cc_library_static", "lib32_bp2build_cc_library_static", AttrNameToString{
|
||||
"local_includes": `["."]`,
|
||||
"target_compatible_with": `["//build/bazel/platforms/os:android"] + select({
|
||||
"//build/bazel/platforms/arch:arm64": ["@platforms//:incompatible"],
|
||||
"//build/bazel/platforms/arch:riscv64": ["@platforms//:incompatible"],
|
||||
"//build/bazel/platforms/arch:x86_64": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
MakeBazelTargetNoRestrictions("cc_library_shared", "lib64", AttrNameToString{
|
||||
"local_includes": `["."]`,
|
||||
"target_compatible_with": `["//build/bazel/platforms/os:android"] + select({
|
||||
"//build/bazel/platforms/arch:arm": ["@platforms//:incompatible"],
|
||||
"//build/bazel/platforms/arch:x86": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
MakeBazelTargetNoRestrictions("cc_library_static", "lib64_bp2build_cc_library_static", AttrNameToString{
|
||||
"local_includes": `["."]`,
|
||||
"target_compatible_with": `["//build/bazel/platforms/os:android"] + select({
|
||||
"//build/bazel/platforms/arch:arm": ["@platforms//:incompatible"],
|
||||
"//build/bazel/platforms/arch:x86": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
}
|
||||
runCcLibraryTestCase(t, tc)
|
||||
}
|
||||
|
Reference in New Issue
Block a user