diff options
Diffstat (limited to 'android/container.go')
-rw-r--r-- | android/container.go | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/android/container.go b/android/container.go index 27b17ed99..5dc97d38e 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) } @@ -170,8 +167,8 @@ var productContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext } var apexContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool { - _, ok := ModuleProvider(mctx, AllApexInfoProvider) - return ok + // TODO(b/394955484): a module can't determine the apexes it belongs to any more + return false } var ctsContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool { @@ -197,10 +194,11 @@ var unstableInfoProvider = blueprint.NewProvider[unstableInfo]() func determineUnstableModule(mctx ModuleContext) bool { module := mctx.Module() + unstableModule := module.Name() == "framework-minus-apex" if installable, ok := module.(InstallableModule); ok { for _, staticDepTag := range installable.StaticDependencyTags() { - mctx.VisitDirectDepsWithTag(staticDepTag, func(dep Module) { + mctx.VisitDirectDepsProxyWithTag(staticDepTag, func(dep ModuleProxy) { if unstableInfo, ok := OtherModuleProvider(mctx, dep, unstableInfoProvider); ok { unstableModule = unstableModule || unstableInfo.ContainsPlatformPrivateApis } @@ -382,7 +380,7 @@ func (c *ContainersInfo) BelongingContainers() []*container { func (c *ContainersInfo) ApexNames() (ret []string) { for _, apex := range c.belongingApexes { - ret = append(ret, apex.InApexVariants...) + ret = append(ret, apex.BaseApexName) } slices.Sort(ret) return ret @@ -400,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 @@ -409,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. @@ -443,19 +441,15 @@ func generateContainerInfo(ctx ModuleContext) ContainersInfo { } } - var belongingApexes []ApexInfo - if apexInfo, ok := ModuleProvider(ctx, AllApexInfoProvider); ok { - belongingApexes = apexInfo.ApexInfos - } - return ContainersInfo{ belongingContainers: containers, - belongingApexes: belongingApexes, + // TODO(b/394955484): a module can't determine the apexes it belongs to any more + belongingApexes: nil, } } func getContainerModuleInfo(ctx ModuleContext, module Module) (ContainersInfo, bool) { - if ctx.Module() == module { + if ctx.EqualModules(ctx.Module(), module) { return ctx.getContainersInfo(), true } @@ -479,8 +473,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 } |