Handle xsd config more like other partitions
This is prep work to add additional special handling for genrule
generated headers as there will be similar partitioning for those
headers.
Test: go test soong tests
Change-Id: Ib63e7e4f7554b2b7b7bc78b2825b20c05403216a
diff --git a/bazel/properties.go b/bazel/properties.go
index 15af09b..702c31c 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -288,6 +288,41 @@
return result
}
+// FirstUniqueBazelLabelListAttribute takes a LabelListAttribute and makes the LabelList for
+// each axis/configuration by keeping the first instance of a Label and omitting all subsequent
+// repetitions.
+func FirstUniqueBazelLabelListAttribute(attr LabelListAttribute) LabelListAttribute {
+ var result LabelListAttribute
+ result.Value = FirstUniqueBazelLabelList(attr.Value)
+ if attr.HasConfigurableValues() {
+ result.ConfigurableValues = make(configurableLabelLists)
+ }
+ for axis, configToLabels := range attr.ConfigurableValues {
+ for c, l := range configToLabels {
+ result.SetSelectValue(axis, c, FirstUniqueBazelLabelList(l))
+ }
+ }
+
+ return result
+}
+
+// SubtractBazelLabelListAttribute subtract needle from haystack for LabelList in each
+// axis/configuration.
+func SubtractBazelLabelListAttribute(haystack LabelListAttribute, needle LabelListAttribute) LabelListAttribute {
+ var result LabelListAttribute
+ result.Value = SubtractBazelLabelList(haystack.Value, needle.Value)
+ if haystack.HasConfigurableValues() {
+ result.ConfigurableValues = make(configurableLabelLists)
+ }
+ for axis, configToLabels := range haystack.ConfigurableValues {
+ for haystackConfig, haystackLabels := range configToLabels {
+ result.SetSelectValue(axis, haystackConfig, SubtractBazelLabelList(haystackLabels, needle.SelectValue(axis, haystackConfig)))
+ }
+ }
+
+ return result
+}
+
type Attribute interface {
HasConfigurableValues() bool
}