diff options
author | Paul Duffin <paulduffin@google.com> | 2020-03-31 15:23:40 +0100 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2020-04-22 12:51:51 +0100 |
commit | b20ad0a7d4c8aa6d88124bacc45555113fa02f70 (patch) | |
tree | 7a298af3ba563bff6b31695bcbf2ac80b0efcbc3 /apex/apex.go | |
parent | f020796cad863165bac690aed22c9202bf04921c (diff) | |
download | build_soong-b20ad0a7d4c8aa6d88124bacc45555113fa02f70.tar.gz build_soong-b20ad0a7d4c8aa6d88124bacc45555113fa02f70.tar.bz2 build_soong-b20ad0a7d4c8aa6d88124bacc45555113fa02f70.zip |
Stop requiring apex_available on java_library members of sdks
Previously, adding java_library to an sdk required that the names of
any APEXes that transitively compiled against it were added to its
apex_available property. This change removes that requirement.
Also corrects the dependency path in the TestApexAvailable_IndirectDep
error which previously passed through "shared from static" static
dependency tags even though those are explicitly NOT followed when
checking apex_available settings.
Bug: 152878661
Bug: 153306490
Test: m droid
Merged-In: I995ed38956c1bc210b09494812de012fed9f9232
Change-Id: I995ed38956c1bc210b09494812de012fed9f9232
Diffstat (limited to 'apex/apex.go')
-rw-r--r-- | apex/apex.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/apex/apex.go b/apex/apex.go index a40a7539..a87187a1 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -868,13 +868,23 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) { mctx.VisitDirectDeps(func(child android.Module) { depName := mctx.OtherModuleName(child) if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() && - cur.DepIsInSameApex(mctx, child) { + (cur.DepIsInSameApex(mctx, child) || inAnySdk(child)) { android.UpdateApexDependency(apexBundles, depName, directDep) am.BuildForApexes(apexBundles) } }) } +// If a module in an APEX depends on a module from an SDK then it needs an APEX +// specific variant created for it. Refer to sdk.sdkDepsReplaceMutator. +func inAnySdk(module android.Module) bool { + if sa, ok := module.(android.SdkAware); ok { + return sa.IsInAnySdk() + } + + return false +} + // Create apex variations if a module is included in APEX(s). func apexMutator(mctx android.BottomUpMutatorContext) { if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { @@ -1849,6 +1859,14 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { apexName := ctx.ModuleName() fromName := ctx.OtherModuleName(from) toName := ctx.OtherModuleName(to) + + // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither + // do any of its dependencies. + if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { + // As soon as the dependency graph crosses the APEX boundary, don't go further. + return false + } + if to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) { return true } |