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
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 9d90a5b..b205c8e 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -1023,6 +1023,13 @@
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,