Merge "mark platform un-availability" am: 01db260858
am: 547c6087df
Change-Id: Ida786db81d3bd1db40cfc28b6f3a013425781345
This commit is contained in:
55
apex/apex.go
55
apex/apex.go
@@ -750,6 +750,7 @@ func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("apex", apexMutator).Parallel()
|
||||
ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
|
||||
ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
|
||||
ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel()
|
||||
}
|
||||
|
||||
// Mark the direct and transitive dependencies of apex bundles so that they
|
||||
@@ -788,6 +789,60 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) {
|
||||
})
|
||||
}
|
||||
|
||||
// mark if a module cannot be available to platform. A module cannot be available
|
||||
// to platform if 1) it is explicitly marked as not available (i.e. "//apex_available:platform"
|
||||
// is absent) or 2) it depends on another module that isn't (or can't be) available to platform
|
||||
func markPlatformAvailability(mctx android.BottomUpMutatorContext) {
|
||||
// Host and recovery are not considered as platform
|
||||
if mctx.Host() || mctx.Module().InstallInRecovery() {
|
||||
return
|
||||
}
|
||||
|
||||
if am, ok := mctx.Module().(android.ApexModule); ok {
|
||||
availableToPlatform := am.AvailableFor(android.AvailableToPlatform)
|
||||
|
||||
// In a rare case when a lib is marked as available only to an apex
|
||||
// but the apex doesn't exist. This can happen in a partial manifest branch
|
||||
// like master-art. Currently, libstatssocket in the stats APEX is causing
|
||||
// this problem.
|
||||
// Include the lib in platform because the module SDK that ought to provide
|
||||
// it doesn't exist, so it would otherwise be left out completely.
|
||||
// TODO(b/154888298) remove this by adding those libraries in module SDKS and skipping
|
||||
// this check for libraries provided by SDKs.
|
||||
if !availableToPlatform && !android.InAnyApex(am.Name()) {
|
||||
availableToPlatform = true
|
||||
}
|
||||
|
||||
// If any of the dep is not available to platform, this module is also considered
|
||||
// as being not available to platform even if it has "//apex_available:platform"
|
||||
mctx.VisitDirectDeps(func(child android.Module) {
|
||||
if !am.DepIsInSameApex(mctx, child) {
|
||||
// if the dependency crosses apex boundary, don't consider it
|
||||
return
|
||||
}
|
||||
if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() {
|
||||
availableToPlatform = false
|
||||
// TODO(b/154889534) trigger an error when 'am' has "//apex_available:platform"
|
||||
}
|
||||
})
|
||||
|
||||
// Exception 1: stub libraries and native bridge libraries are always available to platform
|
||||
if cc, ok := mctx.Module().(*cc.Module); ok &&
|
||||
(cc.IsStubs() || cc.Target().NativeBridge == android.NativeBridgeEnabled) {
|
||||
availableToPlatform = true
|
||||
}
|
||||
|
||||
// Exception 2: bootstrap bionic libraries are also always available to platform
|
||||
if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) {
|
||||
availableToPlatform = true
|
||||
}
|
||||
|
||||
if !availableToPlatform {
|
||||
am.SetNotAvailableForPlatform()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
Reference in New Issue
Block a user