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
This commit is contained in:
Liz Kammer
2022-11-23 09:42:05 -05:00
parent ba36441424
commit ffc17e4edb
4 changed files with 84 additions and 0 deletions

View File

@@ -843,6 +843,26 @@ func (lla *LabelListAttribute) Exclude(axis ConfigurationAxis, config string, la
// 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 {