diff options
| -rw-r--r-- | bp2build/cc_library_conversion_test.go | 34 | ||||
| -rw-r--r-- | cc/bp2build.go | 10 |
2 files changed, 39 insertions, 5 deletions
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go index ba7af0945..4e6f2d106 100644 --- a/bp2build/cc_library_conversion_test.go +++ b/bp2build/cc_library_conversion_test.go @@ -2680,6 +2680,40 @@ cc_library { ) } +func TestCcLibraryStubsAcrossConfigsDuplicatesRemoved(t *testing.T) { + runCcLibraryTestCase(t, Bp2buildTestCase{ + Description: "stub target generation of the same lib across configs should not result in duplicates", + ModuleTypeUnderTest: "cc_library", + ModuleTypeUnderTestFactory: cc.LibraryFactory, + Filesystem: map[string]string{ + "bar.map.txt": "", + }, + Blueprint: ` +cc_library { + name: "barlib", + stubs: { symbol_file: "bar.map.txt", versions: ["28", "29", "current"] }, + bazel_module: { bp2build_available: false }, +} +cc_library { + name: "foolib", + shared_libs: ["barlib"], + target: { + android: { + shared_libs: ["barlib"], + }, + }, + bazel_module: { bp2build_available: true }, +}`, + ExpectedBazelTargets: makeCcLibraryTargets("foolib", AttrNameToString{ + "implementation_dynamic_deps": `select({ + "//build/bazel/rules/apex:android-in_apex": [":barlib_stub_libs_current"], + "//conditions:default": [":barlib"], + })`, + "local_includes": `["."]`, + }), + }) +} + func TestCcLibraryEscapeLdflags(t *testing.T) { runCcLibraryTestCase(t, Bp2buildTestCase{ ModuleTypeUnderTest: "cc_library", diff --git a/cc/bp2build.go b/cc/bp2build.go index 51d8e2270..aea85ec53 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -933,14 +933,14 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion (&inApexSelectValue).Append(bazel.MakeLabelList(stubLibLabels)) (&nonApexSelectValue).Append(bazel.MakeLabelList(depsWithStubs)) (&defaultSelectValue).Append(bazel.MakeLabelList(depsWithStubs)) - la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, inApexSelectValue) - la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, nonApexSelectValue) - la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.ConditionsDefaultConfigKey, defaultSelectValue) + la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.FirstUniqueBazelLabelList(inApexSelectValue)) + la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, bazel.FirstUniqueBazelLabelList(nonApexSelectValue)) + la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.ConditionsDefaultConfigKey, bazel.FirstUniqueBazelLabelList(defaultSelectValue)) } else if config == bazel.OsAndroid { (&inApexSelectValue).Append(bazel.MakeLabelList(stubLibLabels)) (&nonApexSelectValue).Append(bazel.MakeLabelList(depsWithStubs)) - la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, inApexSelectValue) - la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, nonApexSelectValue) + la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.FirstUniqueBazelLabelList(inApexSelectValue)) + la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, bazel.FirstUniqueBazelLabelList(nonApexSelectValue)) } } } |