bp2build: Remove duplicate system shared libs

If a system shared lib is specified in shared_libs, this results in
duplicate values appearing, causing a failure in Bazel. This change
removes any system shared libraries that appear in shared libraries from
bionic OS axes where system_shared_libraries takes the default value.

Test: go soong tests
Test: temporarily allowlist directory with this issue, no longer hits
      duplicate library failure.
Change-Id: I9dce570b73c24973f695b815bce8d50f7259798d
This commit is contained in:
Liz Kammer
2021-12-14 12:21:22 -05:00
parent 7febef761a
commit 5430953c82
4 changed files with 110 additions and 13 deletions

View File

@@ -736,6 +736,24 @@ func (lla LabelListAttribute) IsEmpty() bool {
return true
}
// IsNil returns true if the attribute has not been set for any configuration.
func (lla LabelListAttribute) IsNil() bool {
if lla.Value.Includes != nil {
return false
}
return !lla.HasConfigurableValues()
}
// Exclude for the given axis, config, removes Includes in labelList from Includes and appends them
// to Excludes. This is to special case any excludes that are not specified in a bp file but need to
// be removed, e.g. if they could cause duplicate element failures.
func (lla *LabelListAttribute) Exclude(axis ConfigurationAxis, config string, labelList LabelList) {
val := lla.SelectValue(axis, config)
newList := SubtractBazelLabelList(val, labelList)
newList.Excludes = append(newList.Excludes, labelList.Includes...)
lla.SetSelectValue(axis, config, newList)
}
// ResolveExcludes handles excludes across the various axes, ensuring that items are removed from
// the base value and included in default values as appropriate.
func (lla *LabelListAttribute) ResolveExcludes() {