summaryrefslogtreecommitdiff
path: root/android/container.go
diff options
context:
space:
mode:
author Yu Liu <yudiliu@google.com> 2025-01-07 19:03:34 +0000
committer Yu Liu <yudiliu@google.com> 2025-01-08 23:28:12 +0000
commit97880e1afa6b8749cb3bb67b85cd5c86a95d3519 (patch)
treef4c47893e483217c84fd4bae24854ac3ee95b8fb /android/container.go
parent8a8d5b4b1c714707faf2b9456099ac95fad74b7a (diff)
Convert install and checkContainerViolations to use ModuleProxy.
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: I19ec2142415e88d7486ee58613065f8cdb6aca73
Diffstat (limited to 'android/container.go')
-rw-r--r--android/container.go31
1 files changed, 14 insertions, 17 deletions
diff --git a/android/container.go b/android/container.go
index 830d474e9..882535ebf 100644
--- a/android/container.go
+++ b/android/container.go
@@ -31,28 +31,25 @@ import (
// and the corresponding functions are called from [exceptionHandleFunctionsTable] map.
// ----------------------------------------------------------------------------
-type exceptionHandleFunc func(ModuleContext, Module, Module) bool
+type exceptionHandleFunc func(ModuleContext, Module, ModuleProxy) bool
type StubsAvailableModule interface {
IsStubsModule() bool
}
// Returns true if the dependency module is a stubs module
-var depIsStubsModule exceptionHandleFunc = func(_ ModuleContext, _, dep Module) bool {
- if stubsModule, ok := dep.(StubsAvailableModule); ok {
- return stubsModule.IsStubsModule()
- }
- return false
+var depIsStubsModule exceptionHandleFunc = func(mctx ModuleContext, _ Module, dep ModuleProxy) bool {
+ return OtherModuleProviderOrDefault(mctx, dep, CommonModuleInfoKey).IsStubsModule
}
// Returns true if the dependency module belongs to any of the apexes.
-var depIsApexModule exceptionHandleFunc = func(mctx ModuleContext, _, dep Module) bool {
+var depIsApexModule exceptionHandleFunc = func(mctx ModuleContext, _ Module, dep ModuleProxy) bool {
depContainersInfo, _ := getContainerModuleInfo(mctx, dep)
return InList(ApexContainer, depContainersInfo.belongingContainers)
}
// Returns true if the module and the dependent module belongs to common apexes.
-var belongsToCommonApexes exceptionHandleFunc = func(mctx ModuleContext, m, dep Module) bool {
+var belongsToCommonApexes exceptionHandleFunc = func(mctx ModuleContext, m Module, dep ModuleProxy) bool {
mContainersInfo, _ := getContainerModuleInfo(mctx, m)
depContainersInfo, _ := getContainerModuleInfo(mctx, dep)
@@ -62,7 +59,7 @@ var belongsToCommonApexes exceptionHandleFunc = func(mctx ModuleContext, m, dep
// Returns true when all apexes that the module belongs to are non updatable.
// For an apex module to be allowed to depend on a non-apex partition module,
// all apexes that the module belong to must be non updatable.
-var belongsToNonUpdatableApex exceptionHandleFunc = func(mctx ModuleContext, m, _ Module) bool {
+var belongsToNonUpdatableApex exceptionHandleFunc = func(mctx ModuleContext, m Module, _ ModuleProxy) bool {
mContainersInfo, _ := getContainerModuleInfo(mctx, m)
return !mContainersInfo.UpdatableApex()
@@ -70,7 +67,7 @@ var belongsToNonUpdatableApex exceptionHandleFunc = func(mctx ModuleContext, m,
// Returns true if the dependency is added via dependency tags that are not used to tag dynamic
// dependency tags.
-var depIsNotDynamicDepTag exceptionHandleFunc = func(ctx ModuleContext, m, dep Module) bool {
+var depIsNotDynamicDepTag exceptionHandleFunc = func(ctx ModuleContext, m Module, dep ModuleProxy) bool {
mInstallable, _ := m.(InstallableModule)
depTag := ctx.OtherModuleDependencyTag(dep)
return !InList(depTag, mInstallable.DynamicDependencyTags())
@@ -79,7 +76,7 @@ var depIsNotDynamicDepTag exceptionHandleFunc = func(ctx ModuleContext, m, dep M
// Returns true if the dependency is added via dependency tags that are not used to tag static
// or dynamic dependency tags. These dependencies do not affect the module in compile time or in
// runtime, thus are not significant enough to raise an error.
-var depIsNotStaticOrDynamicDepTag exceptionHandleFunc = func(ctx ModuleContext, m, dep Module) bool {
+var depIsNotStaticOrDynamicDepTag exceptionHandleFunc = func(ctx ModuleContext, m Module, dep ModuleProxy) bool {
mInstallable, _ := m.(InstallableModule)
depTag := ctx.OtherModuleDependencyTag(dep)
return !InList(depTag, append(mInstallable.StaticDependencyTags(), mInstallable.DynamicDependencyTags()...))
@@ -106,7 +103,7 @@ var globallyAllowlistedDependencies = []string{
}
// Returns true when the dependency is globally allowlisted for inter-container dependency
-var depIsGloballyAllowlisted exceptionHandleFunc = func(_ ModuleContext, _, dep Module) bool {
+var depIsGloballyAllowlisted exceptionHandleFunc = func(_ ModuleContext, _ Module, dep ModuleProxy) bool {
return InList(dep.Name(), globallyAllowlistedDependencies)
}
@@ -401,7 +398,7 @@ func (c *ContainersInfo) UpdatableApex() bool {
var ContainersInfoProvider = blueprint.NewProvider[ContainersInfo]()
-func satisfyAllowedExceptions(ctx ModuleContext, allowedExceptionLabels []exceptionHandleFuncLabel, m, dep Module) bool {
+func satisfyAllowedExceptions(ctx ModuleContext, allowedExceptionLabels []exceptionHandleFuncLabel, m Module, dep ModuleProxy) bool {
for _, label := range allowedExceptionLabels {
if exceptionHandleFunctionsTable[label](ctx, m, dep) {
return true
@@ -410,7 +407,7 @@ func satisfyAllowedExceptions(ctx ModuleContext, allowedExceptionLabels []except
return false
}
-func (c *ContainersInfo) GetViolations(mctx ModuleContext, m, dep Module, depInfo ContainersInfo) []string {
+func (c *ContainersInfo) GetViolations(mctx ModuleContext, m Module, dep ModuleProxy, depInfo ContainersInfo) []string {
var violations []string
// Any containers that the module belongs to but the dependency does not belong to must be examined.
@@ -456,7 +453,7 @@ func generateContainerInfo(ctx ModuleContext) ContainersInfo {
}
func getContainerModuleInfo(ctx ModuleContext, module Module) (ContainersInfo, bool) {
- if ctx.Module() == module {
+ if ctx.EqualModules(ctx.Module(), module) {
return ctx.getContainersInfo(), true
}
@@ -480,8 +477,8 @@ func setContainerInfo(ctx ModuleContext) {
func checkContainerViolations(ctx ModuleContext) {
if _, ok := ctx.Module().(InstallableModule); ok {
containersInfo, _ := getContainerModuleInfo(ctx, ctx.Module())
- ctx.VisitDirectDeps(func(dep Module) {
- if !dep.Enabled(ctx) {
+ ctx.VisitDirectDepsProxy(func(dep ModuleProxy) {
+ if !OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoKey).Enabled {
return
}