Fix apex_available

Checking apex_available was missing some corner cases.
For example, the deps of share deps of cc_library modules are missed
while those from cc_library_shared are correctly tracked.

This was due to..

* calling DepIsInSameApex in WalkDeps: both work fine separately, but
when they are used together, it fails to work. It's due to how WalkDeps
works. (We might fix this bug too risky since it is used very widely)
* incorrect receiver for DepIsInSameApex in apex_deps mutator: receiver
is supposed to be parent, but child was used before. Interestingly lots
of deps are within the same group of module types(cc to cc, java to
java), it has worked. (note that receiver's DepIsInSameApex
implementation can be different).

This change fixes them by..

* walkPayloadDeps is now relying on ApexVariation, which is calculated
correctly by TopDown apex_deps mutator.
* use correct receiver for DepIsInSameApex in apex_deps mutator, which
requires for java.SdkLibrary to override the method and for
java.Library/Import to use passed dep instead of receiver to check its
membership of sdk.

Exempt-From-Owner-Approval: cherry-pick from aosp/master

Bug: 151071238
Test: build/boot
Merged-In: I0569ef4bb8e79635e4d97a89f421a8d8b7d26456
(cherry picked from commit 5e9013be22)
Change-Id: I0569ef4bb8e79635e4d97a89f421a8d8b7d26456
This commit is contained in:
Jooyung Han
2020-03-10 06:23:13 +09:00
committed by Jiyong Park
parent 5a3899b5c5
commit b8fa86ad6f
5 changed files with 75 additions and 31 deletions

View File

@@ -1790,11 +1790,16 @@ func (j *Module) hasCode(ctx android.ModuleContext) bool {
}
func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
depTag := ctx.OtherModuleDependencyTag(dep)
// Dependencies other than the static linkage are all considered crossing APEX boundary
if staticLibTag == ctx.OtherModuleDependencyTag(dep) {
return true
}
// Also, a dependency to an sdk member is also considered as such. This is required because
// sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator.
return depTag == staticLibTag || j.IsInAnySdk()
if sa, ok := dep.(android.SdkAware); ok && sa.IsInAnySdk() {
return true
}
return false
}
func (j *Module) Stem() string {
@@ -2495,11 +2500,16 @@ func (j *Import) SrcJarArgs() ([]string, android.Paths) {
}
func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
depTag := ctx.OtherModuleDependencyTag(dep)
// dependencies other than the static linkage are all considered crossing APEX boundary
if staticLibTag == ctx.OtherModuleDependencyTag(dep) {
return true
}
// Also, a dependency to an sdk member is also considered as such. This is required because
// sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator.
return depTag == staticLibTag || j.IsInAnySdk()
if sa, ok := dep.(android.SdkAware); ok && sa.IsInAnySdk() {
return true
}
return false
}
// Add compile time check for interface implementation