Merge "Remove apex_available tag in cc_library_static generated from stubs-providing lib"

This commit is contained in:
Vinh Tran 2023-01-10 15:30:11 +00:00 committed by Gerrit Code Review
commit 57b1e4064b
2 changed files with 79 additions and 3 deletions

View file

@ -1146,6 +1146,76 @@ apex {
}})
}
func TestApexWithStubLib(t *testing.T) {
runApexTestCase(t, Bp2buildTestCase{
Description: "apex - static variant of stub lib should not have apex_available tag",
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
Filesystem: map[string]string{},
Blueprint: `
cc_library{
name: "foo",
stubs: { symbol_file: "foo.map.txt", versions: ["28", "29", "current"] },
apex_available: ["myapex"],
}
cc_binary{
name: "bar",
static_libs: ["foo"],
apex_available: ["myapex"],
}
apex {
name: "myapex",
manifest: "myapex_manifest.json",
file_contexts: ":myapex-file_contexts",
binaries: ["bar"],
native_shared_libs: ["foo"],
}
` + simpleModuleDoNotConvertBp2build("filegroup", "myapex-file_contexts"),
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_binary", "bar", AttrNameToString{
"local_includes": `["."]`,
"deps": `[":foo_bp2build_cc_library_static"]`,
"tags": `["apex_available=myapex"]`,
}),
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
"local_includes": `["."]`,
}),
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
"local_includes": `["."]`,
"stubs_symbol_file": `"foo.map.txt"`,
"tags": `["apex_available=myapex"]`,
}),
MakeBazelTarget("cc_stub_suite", "foo_stub_libs", AttrNameToString{
"soname": `"foo.so"`,
"source_library": `":foo"`,
"symbol_file": `"foo.map.txt"`,
"versions": `[
"28",
"29",
"current",
]`,
}),
MakeBazelTarget("apex", "myapex", AttrNameToString{
"file_contexts": `":myapex-file_contexts"`,
"manifest": `"myapex_manifest.json"`,
"binaries": `[":bar"]`,
"native_shared_libs_32": `select({
"//build/bazel/platforms/arch:arm": [":foo"],
"//build/bazel/platforms/arch:x86": [":foo"],
"//conditions:default": [],
})`,
"native_shared_libs_64": `select({
"//build/bazel/platforms/arch:arm64": [":foo"],
"//build/bazel/platforms/arch:x86_64": [":foo"],
"//conditions:default": [],
})`,
}),
},
})
}
func TestApexCertificateIsSrc(t *testing.T) {
runApexTestCase(t, Bp2buildTestCase{
Description: "apex - certificate is src",

View file

@ -436,17 +436,23 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
Bzl_load_location: "//build/bazel/rules/cc:cc_library_shared.bzl",
}
tags := android.ApexAvailableTags(m)
var tagsForStaticVariant bazel.StringListAttribute
if compilerAttrs.stubsSymbolFile == nil && len(compilerAttrs.stubsVersions.Value) == 0 {
tagsForStaticVariant = android.ApexAvailableTags(m)
}
tagsForSharedVariant := android.ApexAvailableTags(m)
ctx.CreateBazelTargetModuleWithRestrictions(staticProps,
android.CommonAttributes{
Name: m.Name() + "_bp2build_cc_library_static",
Tags: tags,
Tags: tagsForStaticVariant,
},
staticTargetAttrs, staticAttrs.Enabled)
ctx.CreateBazelTargetModuleWithRestrictions(sharedProps,
android.CommonAttributes{
Name: m.Name(),
Tags: tags,
Tags: tagsForSharedVariant,
},
sharedTargetAttrs, sharedAttrs.Enabled)