Print default val if all vals in axis match default val
To avoid verbosity, we currently dedupe keys in axis if its value
matches the value of //conditions:default. For axes where all values
might match the default value, we would effectively drop the common
value.
To fix this, we are now dropping the select statement and not the common
value.
Test: go test ./bp2build
Change-Id: Ic377b93ee2aba971753f6a5e7a62e15d1fcfa2bc
diff --git a/bp2build/configurability.go b/bp2build/configurability.go
index 8e17103..3d9f0a2 100644
--- a/bp2build/configurability.go
+++ b/bp2build/configurability.go
@@ -279,6 +279,10 @@
}
if len(selects) == 0 {
+ // If there is a default value, and there are no selects for this axis, print that without any selects.
+ if val, exists := selectMap[bazel.ConditionsDefaultSelectKey]; exists {
+ return prettyPrint(val, indent, emitZeroValues)
+ }
// No conditions (or all values are empty lists), so no need for a map.
return "", nil
}