diff options
| author | 2023-01-10 15:30:11 +0000 | |
|---|---|---|
| committer | 2023-01-10 15:30:11 +0000 | |
| commit | 57b1e4064be7b3a0976da7a5c474ebef9f65312d (patch) | |
| tree | d2dfc359c425f74208f73e1ad1f0e90a59947115 | |
| parent | 58358630def5627ecc20c00d57e4f514037afb9d (diff) | |
| parent | 55225e343dd406a711f260406fbe5c636b15f356 (diff) | |
Merge "Remove apex_available tag in cc_library_static generated from stubs-providing lib"
| -rw-r--r-- | bp2build/apex_conversion_test.go | 70 | ||||
| -rw-r--r-- | cc/library.go | 12 |
2 files changed, 79 insertions, 3 deletions
diff --git a/bp2build/apex_conversion_test.go b/bp2build/apex_conversion_test.go index 714b8488a..1c0e56308 100644 --- a/bp2build/apex_conversion_test.go +++ b/bp2build/apex_conversion_test.go @@ -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", diff --git a/cc/library.go b/cc/library.go index 4b4751588..787de4403 100644 --- a/cc/library.go +++ b/cc/library.go @@ -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) |