diff options
author | 2025-03-04 19:30:25 +0000 | |
---|---|---|
committer | 2025-03-07 23:16:55 +0000 | |
commit | e263a697bc5a17ddcabc36d9c16588a8743756db (patch) | |
tree | 1c3a55d22e89b70d2df663a1edeee432664e4f83 | |
parent | ef9e63e775493bd73cb28917ad59e6b10e5506b5 (diff) |
Convert WalkPayloadDeps to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: If0d132c2310eb958c066747f9c16251cc24fedd0
-rw-r--r-- | android/apex.go | 4 | ||||
-rw-r--r-- | apex/apex.go | 31 | ||||
-rw-r--r-- | apex/builder.go | 2 | ||||
-rw-r--r-- | java/app.go | 8 | ||||
-rw-r--r-- | java/sdk_library.go | 6 |
5 files changed, 12 insertions, 39 deletions
diff --git a/android/apex.go b/android/apex.go index 2af3f9dc7..57baff5cf 100644 --- a/android/apex.go +++ b/android/apex.go @@ -695,7 +695,7 @@ func (d *ApexBundleDepsInfo) BuildDepsInfoLists(ctx ModuleContext, minSdkVersion // Function called while walking an APEX's payload dependencies. // // Return true if the `to` module should be visited, false otherwise. -type PayloadDepsCallback func(ctx BaseModuleContext, from Module, to ApexModule, externalDep bool) bool +type PayloadDepsCallback func(ctx BaseModuleContext, from, to ModuleProxy, externalDep bool) bool type WalkPayloadDepsFunc func(ctx BaseModuleContext, do PayloadDepsCallback) // ModuleWithMinSdkVersionCheck represents a module that implements min_sdk_version checks @@ -723,7 +723,7 @@ func CheckMinSdkVersion(ctx ModuleContext, minSdkVersion ApiLevel, walk WalkPayl return } - walk(ctx, func(ctx BaseModuleContext, from Module, to ApexModule, externalDep bool) bool { + walk(ctx, func(ctx BaseModuleContext, from, to ModuleProxy, externalDep bool) bool { if externalDep { // external deps are outside the payload boundary, which is "stable" // interface. We don't have to check min_sdk_version for external diff --git a/apex/apex.go b/apex/apex.go index 5cdfc23fb..dc44e5849 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1607,33 +1607,6 @@ func apexFileForFilesystem(ctx android.BaseModuleContext, buildFile android.Path // to the child modules. Returning false makes the visit to continue in the sibling or the parent // modules. This is used in check* functions below. func (a *apexBundle) WalkPayloadDeps(ctx android.BaseModuleContext, do android.PayloadDepsCallback) { - ctx.WalkDeps(func(child, parent android.Module) bool { - am, ok := child.(android.ApexModule) - if !ok || !am.CanHaveApexVariants() { - return false - } - - // Filter-out unwanted depedendencies - depTag := ctx.OtherModuleDependencyTag(child) - if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { - return false - } - if dt, ok := depTag.(*dependencyTag); ok && !dt.payload { - return false - } - if depTag == android.RequiredDepTag { - return false - } - - externalDep := !android.IsDepInSameApex(ctx, parent, child) - - // Visit actually - return do(ctx, parent, am, externalDep) - }) -} - -func (a *apexBundle) WalkPayloadDepsProxy(ctx android.BaseModuleContext, - do func(ctx android.BaseModuleContext, from, to android.ModuleProxy, externalDep bool) bool) { ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool { if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).CanHaveApexVariants { return false @@ -2557,7 +2530,7 @@ func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext librariesDirectlyInApex[ctx.OtherModuleName(dep)] = true }) - a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from android.Module, to android.ApexModule, externalDep bool) bool { + a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from, to android.ModuleProxy, externalDep bool) bool { if info, ok := android.OtherModuleProvider(ctx, to, cc.LinkableInfoProvider); ok { // 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. @@ -2671,7 +2644,7 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { return } - a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from android.Module, to android.ApexModule, externalDep bool) bool { + a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from, to android.ModuleProxy, externalDep bool) bool { // As soon as the dependency graph crosses the APEX boundary, don't go further. if externalDep { return false diff --git a/apex/builder.go b/apex/builder.go index 6c500de8d..8042a3b88 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -1102,7 +1102,7 @@ func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) { } depInfos := android.DepNameToDepInfoMap{} - a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from android.Module, to android.ApexModule, externalDep bool) bool { + a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from, to android.ModuleProxy, externalDep bool) bool { if from.Name() == to.Name() { // This can happen for cc.reuseObjTag. We are not interested in tracking this. // As soon as the dependency graph crosses the APEX boundary, don't go further. diff --git a/java/app.go b/java/app.go index 3fab89119..f1dcf4176 100644 --- a/java/app.go +++ b/java/app.go @@ -1287,13 +1287,13 @@ func collectJniDeps(ctx android.ModuleContext, } func (a *AndroidApp) WalkPayloadDeps(ctx android.BaseModuleContext, do android.PayloadDepsCallback) { - ctx.WalkDeps(func(child, parent android.Module) bool { + ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool { // TODO(ccross): Should this use android.DepIsInSameApex? Right now it is applying the android app // heuristics to every transitive dependency, when it should probably be using the heuristics of the // immediate parent. isExternal := !a.GetDepInSameApexChecker().OutgoingDepIsInSameApex(ctx.OtherModuleDependencyTag(child)) - if am, ok := child.(android.ApexModule); ok { - if !do(ctx, parent, am, isExternal) { + if am, ok := android.OtherModuleProvider(ctx, child, android.CommonModuleInfoProvider); ok && am.IsApexModule { + if !do(ctx, parent, child, isExternal) { return false } } @@ -1307,7 +1307,7 @@ func (a *AndroidApp) buildAppDependencyInfo(ctx android.ModuleContext) { } depsInfo := android.DepNameToDepInfoMap{} - a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from android.Module, to android.ApexModule, externalDep bool) bool { + a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from, to android.ModuleProxy, externalDep bool) bool { depName := to.Name() // Skip dependencies that are only available to APEXes; they are developed with updatability diff --git a/java/sdk_library.go b/java/sdk_library.go index 0fee529e9..00ba8b2fb 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1337,10 +1337,10 @@ func (module *SdkLibrary) CheckMinSdkVersion(ctx android.ModuleContext) { func CheckMinSdkVersion(ctx android.ModuleContext, module *Library) { android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx), func(c android.BaseModuleContext, do android.PayloadDepsCallback) { - ctx.WalkDeps(func(child android.Module, parent android.Module) bool { + ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool { isExternal := !android.IsDepInSameApex(ctx, module, child) - if am, ok := child.(android.ApexModule); ok { - if !do(ctx, parent, am, isExternal) { + if am, ok := android.OtherModuleProvider(ctx, child, android.CommonModuleInfoProvider); ok && am.IsApexModule { + if !do(ctx, parent, child, isExternal) { return false } } |