Use excludes from OS axis for OsAndInApex
The axis for OS and in APEX was previously ignoring the excludes from
OS, which would result in excludes for non-Android OSes being
incorrectly ignored.
Test: go test Soong tests
Test: b build //hardware/libhardware:all
Bug: 260131489
Change-Id: Ie77f763bea0f473ac69a0c6b6bc3216e7359ad12
diff --git a/bazel/properties.go b/bazel/properties.go
index 823cda8..ee9609a 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -843,6 +843,26 @@
// 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() {
+ // If there are OsAndInApexAxis, we need to use
+ // * includes from the OS & in APEX Axis for non-Android configs for libraries that need to be
+ // included in non-Android OSes
+ // * excludes from the OS Axis for non-Android configs, to exclude libraries that should _not_
+ // be included in the non-Android OSes
+ if _, ok := lla.ConfigurableValues[OsAndInApexAxis]; ok {
+ inApexLabels := lla.ConfigurableValues[OsAndInApexAxis][ConditionsDefaultConfigKey]
+ for config, labels := range lla.ConfigurableValues[OsConfigurationAxis] {
+ // OsAndroid has already handled its excludes.
+ // We only need to copy the excludes from other arches, so if there are none, skip it.
+ if config == OsAndroid || len(labels.Excludes) == 0 {
+ continue
+ }
+ lla.ConfigurableValues[OsAndInApexAxis][config] = LabelList{
+ Includes: inApexLabels.Includes,
+ Excludes: labels.Excludes,
+ }
+ }
+ }
+
for axis, configToLabels := range lla.ConfigurableValues {
baseLabels := lla.Value.deepCopy()
for config, val := range configToLabels {