summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2025-01-14 13:27:00 -0800
committer Cole Faust <colefaust@google.com> 2025-01-14 13:27:00 -0800
commit19eb09d8116122626b3083c033ec37cf17298e0d (patch)
tree765c4dbf0f297e5f3d636b7e5019957f70a5fac7
parent5ccdca9babe6139206710a3c0595f35412c92d63 (diff)
Unwrap ModuleProxy pointers
GetDirectDepProxyWithTag returns a *ModuleProxy. Update getWrappedModule to unwrap *ModuleProxy instances in addition to ModuleProxy so that GetDirectDepProxyWithTag can be a drop-in replacement for GetDirectDepWithTag. I think we should also consider not exposing ModuleProxy to users directly, and instead only expose it via the Module interface. Bug: 377723687 Test: m nothing Change-Id: I188105a4638090d53e2821d86c2738bfdafe5217
-rw-r--r--android/base_module_context.go5
-rw-r--r--filesystem/android_device.go16
2 files changed, 12 insertions, 9 deletions
diff --git a/android/base_module_context.go b/android/base_module_context.go
index d8558d0e5..4b90083be 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -254,6 +254,9 @@ type baseModuleContext struct {
}
func getWrappedModule(module blueprint.Module) blueprint.Module {
+ if mp, isProxy := module.(*ModuleProxy); isProxy {
+ return mp.module
+ }
if mp, isProxy := module.(ModuleProxy); isProxy {
return mp.module
}
@@ -291,7 +294,7 @@ func (b *baseModuleContext) OtherModuleType(m blueprint.Module) string {
}
func (b *baseModuleContext) otherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) {
- return b.bp.OtherModuleProvider(m, provider)
+ return b.bp.OtherModuleProvider(getWrappedModule(m), provider)
}
func (b *baseModuleContext) OtherModuleIsAutoGenerated(m blueprint.Module) bool {
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 83cac748f..c8c535475 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -145,7 +145,7 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.buildTargetFilesZip(ctx)
var deps []android.Path
if proptools.String(a.partitionProps.Super_partition_name) != "" {
- superImage := ctx.GetDirectDepWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
+ superImage := ctx.GetDirectDepProxyWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
if info, ok := android.OtherModuleProvider(ctx, superImage, SuperImageProvider); ok {
assertUnset := func(prop *string, propName string) {
if prop != nil && *prop != "" {
@@ -182,7 +182,7 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.ModuleErrorf("Expected super image dep to provide SuperImageProvider")
}
}
- ctx.VisitDirectDepsWithTag(filesystemDepTag, func(m android.Module) {
+ ctx.VisitDirectDepsProxyWithTag(filesystemDepTag, func(m android.ModuleProxy) {
imageOutput, ok := android.OtherModuleProvider(ctx, m, android.OutputFilesProvider)
if !ok {
ctx.ModuleErrorf("Partition module %s doesn't set OutputfilesProvider", m.Name())
@@ -274,7 +274,7 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
}
// Get additional filesystems from super_partition dependency
if a.partitionProps.Super_partition_name != nil {
- superPartition := ctx.GetDirectDepWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
+ superPartition := ctx.GetDirectDepProxyWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
if info, ok := android.OtherModuleProvider(ctx, superPartition, SuperImageProvider); ok {
for _, partition := range android.SortedStringKeys(info.SubImageInfo) {
filesystemsToCopy = append(
@@ -305,7 +305,7 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
}
// Copy cmdline, kernel etc. files of boot images
if a.partitionProps.Vendor_boot_partition_name != nil {
- bootImg := ctx.GetDirectDepWithTag(proptools.String(a.partitionProps.Vendor_boot_partition_name), filesystemDepTag)
+ bootImg := ctx.GetDirectDepProxyWithTag(proptools.String(a.partitionProps.Vendor_boot_partition_name), filesystemDepTag)
bootImgInfo, _ := android.OtherModuleProvider(ctx, bootImg, BootimgInfoProvider)
builder.Command().Textf("echo %s > %s/VENDOR_BOOT/cmdline", proptools.ShellEscape(strings.Join(bootImgInfo.Cmdline, " ")), targetFilesDir)
builder.Command().Textf("echo %s > %s/VENDOR_BOOT/vendor_cmdline", proptools.ShellEscape(strings.Join(bootImgInfo.Cmdline, " ")), targetFilesDir)
@@ -317,7 +317,7 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
}
}
if a.partitionProps.Boot_partition_name != nil {
- bootImg := ctx.GetDirectDepWithTag(proptools.String(a.partitionProps.Boot_partition_name), filesystemDepTag)
+ bootImg := ctx.GetDirectDepProxyWithTag(proptools.String(a.partitionProps.Boot_partition_name), filesystemDepTag)
bootImgInfo, _ := android.OtherModuleProvider(ctx, bootImg, BootimgInfoProvider)
builder.Command().Textf("echo %s > %s/BOOT/cmdline", proptools.ShellEscape(strings.Join(bootImgInfo.Cmdline, " ")), targetFilesDir)
if bootImgInfo.Dtb != nil {
@@ -374,9 +374,9 @@ func (a *androidDevice) copyImagesToTargetZip(ctx android.ModuleContext, builder
})
if a.partitionProps.Super_partition_name != nil {
- superPartition := ctx.GetDirectDepWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
+ superPartition := ctx.GetDirectDepProxyWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
if info, ok := android.OtherModuleProvider(ctx, superPartition, SuperImageProvider); ok {
- for _, partition := range android.SortedStringKeys(info.SubImageInfo) {
+ for _, partition := range android.SortedKeys(info.SubImageInfo) {
builder.Command().Textf("cp ").Input(info.SubImageInfo[partition].Output).Textf(" %s/IMAGES/", targetFilesDir.String())
}
} else {
@@ -386,7 +386,7 @@ func (a *androidDevice) copyImagesToTargetZip(ctx android.ModuleContext, builder
}
func (a *androidDevice) getFilesystemInfo(ctx android.ModuleContext, depName string) FilesystemInfo {
- fsMod := ctx.GetDirectDepWithTag(depName, filesystemDepTag)
+ fsMod := ctx.GetDirectDepProxyWithTag(depName, filesystemDepTag)
fsInfo, ok := android.OtherModuleProvider(ctx, fsMod, FilesystemProvider)
if !ok {
ctx.ModuleErrorf("Expected dependency %s to be a filesystem", depName)