Remove TestApexes from ApexInfo
TestApexes is used to enforce the "Stub libraries should have a single
apex_available" check, but requires propagating information from
multiple apexes in order to filter out the test apexes. Instead,
all test apexes used by stub libraries will set apex_available_name
to masquerade as their non-test counterpart for apex_available
checks.
Bug: 383592644
Test: TestStubLibrariesMultipleApexViolation
Change-Id: I57dcf1e6fabbe70f40d702490b93fc7f28d6eba2
diff --git a/cc/cc.go b/cc/cc.go
index 284ab8b..757db0f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1904,13 +1904,13 @@
return false
}
- _, aaWithoutTestApexes, _ := android.ListSetDifference(c.ApexAvailable(), c.TestApexes())
// Stub libraries should not have more than one apex_available
- if len(aaWithoutTestApexes) > 1 {
+ apexAvailable := android.FirstUniqueStrings(c.ApexAvailable())
+ if len(apexAvailable) > 1 {
return true
}
// Stub libraries should not use the wildcard
- if aaWithoutTestApexes[0] == android.AvailableToAnyApex {
+ if apexAvailable[0] == android.AvailableToAnyApex {
return true
}
// Default: no violation