From f3ab29be2d91026bca9e381f4cc7e9bbfae6e98d Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 17 Aug 2023 00:23:59 +0000 Subject: [PATCH] Dedupe all deps of cc_libraries Without an explicit deduping in this helper function, a dependency may appear multiple times in the generated BUILD files. I noticed this while converting some internal google tests. This currently does the deduping for the non-configurable root value. I ran into some issues deduping the configurable values, and I will address it in a followup CL. Test: go test ./bp2build Change-Id: Ie7b588a9c922d72e4fabfb1414a7cc3dc402ff86 --- cc/bp2build.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cc/bp2build.go b/cc/bp2build.go index 9d90a5b5d..b205c8e1a 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -1023,6 +1023,13 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module) addMuslSystemDynamicDeps(ctx, linkerAttrs) + // Dedupe all deps. + (&linkerAttrs).deps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).deps.Value) + (&linkerAttrs).implementationDeps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).implementationDeps.Value) + (&linkerAttrs).implementationDynamicDeps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).implementationDynamicDeps.Value) + (&linkerAttrs).wholeArchiveDeps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).wholeArchiveDeps.Value) + (&linkerAttrs).implementationWholeArchiveDeps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).implementationWholeArchiveDeps.Value) + return baseAttributes{ compilerAttrs, linkerAttrs,