summaryrefslogtreecommitdiff
path: root/filesystem/android_device.go
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2025-01-13 22:17:40 +0000
committer Spandan Das <spandandas@google.com> 2025-01-14 04:57:48 +0000
commitef77574bbcb56086e7bc5f5edcd20ea8e813fa93 (patch)
treec220dd4631da6710be24f2facd8e3ee1178d46fe /filesystem/android_device.go
parentc68fa5aff3defe1f37b707f81cb78722cc121ec6 (diff)
Get filesystemInfo from Super_image dep
https://r.android.com/3447508 added super_img to the deps of the autogenerated android_device module, and also removed the individual partitions from the direct deps. This CL updates the target_files.zip generation logic to get the FilesystemInfo(s) from the super_image dependency This CL also contains an additional fix for https://r.android.com/3446350 (bootimg). bootimg currently sets both BootimgInfoProvider as well FilesystemInfoProvider (for its ramdisk). Checking bootimgProvider first ensures that the boot.img file is copied, and not its ramdisk.img Test: Diff'd locally Bug: 388635097 Change-Id: I654c8eb72ed7b19a955170db1a12a737fbaa8079
Diffstat (limited to 'filesystem/android_device.go')
-rw-r--r--filesystem/android_device.go60
1 files changed, 49 insertions, 11 deletions
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 98a56d79b..d9f38163b 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -225,11 +225,17 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
}
+// Helper structs for target_files.zip creation
type targetFilesZipCopy struct {
srcModule *string
destSubdir string
}
+type targetFilesystemZipCopy struct {
+ fsInfo FilesystemInfo
+ destSubdir string
+}
+
func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
targetFilesDir := android.PathForModuleOut(ctx, "target_files_dir")
targetFilesZip := android.PathForModuleOut(ctx, "target_files.zip")
@@ -256,25 +262,45 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
toCopy = append(toCopy, targetFilesZipCopy{a.partitionProps.Recovery_partition_name, "VENDOR_BOOT/RAMDISK"})
}
+ filesystemsToCopy := []targetFilesystemZipCopy{}
for _, zipCopy := range toCopy {
if zipCopy.srcModule == nil {
continue
}
- fsInfo := a.getFilesystemInfo(ctx, *zipCopy.srcModule)
- subdir := zipCopy.destSubdir
- rootDirString := fsInfo.RootDir.String()
- if subdir == "SYSTEM" {
+ filesystemsToCopy = append(
+ filesystemsToCopy,
+ targetFilesystemZipCopy{a.getFilesystemInfo(ctx, *zipCopy.srcModule), zipCopy.destSubdir},
+ )
+ }
+ // Get additional filesystems from super_partition dependency
+ if a.partitionProps.Super_partition_name != nil {
+ superPartition := ctx.GetDirectDepWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
+ if info, ok := android.OtherModuleProvider(ctx, superPartition, SuperImageProvider); ok {
+ for _, partition := range android.SortedStringKeys(info.SubImageInfo) {
+ filesystemsToCopy = append(
+ filesystemsToCopy,
+ targetFilesystemZipCopy{info.SubImageInfo[partition], strings.ToUpper(partition)},
+ )
+ }
+ } else {
+ ctx.ModuleErrorf("Super partition %s does set SuperImageProvider\n", superPartition.Name())
+ }
+ }
+
+ for _, toCopy := range filesystemsToCopy {
+ rootDirString := toCopy.fsInfo.RootDir.String()
+ if toCopy.destSubdir == "SYSTEM" {
rootDirString = rootDirString + "/system"
}
- builder.Command().Textf("mkdir -p %s/%s", targetFilesDir.String(), subdir)
+ builder.Command().Textf("mkdir -p %s/%s", targetFilesDir.String(), toCopy.destSubdir)
builder.Command().
BuiltTool("acp").
- Textf("-rd %s/. %s/%s", rootDirString, targetFilesDir, subdir).
- Implicit(fsInfo.Output) // so that the staging dir is built
+ Textf("-rd %s/. %s/%s", rootDirString, targetFilesDir, toCopy.destSubdir).
+ Implicit(toCopy.fsInfo.Output) // so that the staging dir is built
- if subdir == "SYSTEM" {
+ if toCopy.destSubdir == "SYSTEM" {
// Create the ROOT partition in target_files.zip
- builder.Command().Textf("rsync --links --exclude=system/* %s/ -r %s/ROOT", fsInfo.RootDir, targetFilesDir.String())
+ builder.Command().Textf("rsync --links --exclude=system/* %s/ -r %s/ROOT", toCopy.fsInfo.RootDir, targetFilesDir.String())
}
}
// Copy cmdline, kernel etc. files of boot images
@@ -332,9 +358,10 @@ func (a *androidDevice) copyImagesToTargetZip(ctx android.ModuleContext, builder
}
// Copy the filesystem ,boot and vbmeta img files to IMAGES/
ctx.VisitDirectDepsProxyWithTag(filesystemDepTag, func(child android.ModuleProxy) {
- if info, ok := android.OtherModuleProvider(ctx, child, FilesystemProvider); ok {
+ if info, ok := android.OtherModuleProvider(ctx, child, BootimgInfoProvider); ok {
+ // Check Boot img first so that the boot.img is copied and not its dep ramdisk.img
builder.Command().Textf("cp ").Input(info.Output).Textf(" %s/IMAGES/", targetFilesDir.String())
- } else if info, ok := android.OtherModuleProvider(ctx, child, BootimgInfoProvider); ok {
+ } else if info, ok := android.OtherModuleProvider(ctx, child, FilesystemProvider); ok {
builder.Command().Textf("cp ").Input(info.Output).Textf(" %s/IMAGES/", targetFilesDir.String())
} else if info, ok := android.OtherModuleProvider(ctx, child, vbmetaPartitionProvider); ok {
builder.Command().Textf("cp ").Input(info.Output).Textf(" %s/IMAGES/", targetFilesDir.String())
@@ -342,6 +369,17 @@ func (a *androidDevice) copyImagesToTargetZip(ctx android.ModuleContext, builder
ctx.ModuleErrorf("Module %s does not provide an .img file output for target_files.zip", child.Name())
}
})
+
+ if a.partitionProps.Super_partition_name != nil {
+ superPartition := ctx.GetDirectDepWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
+ if info, ok := android.OtherModuleProvider(ctx, superPartition, SuperImageProvider); ok {
+ for _, partition := range android.SortedStringKeys(info.SubImageInfo) {
+ builder.Command().Textf("cp ").Input(info.SubImageInfo[partition].Output).Textf(" %s/IMAGES/", targetFilesDir.String())
+ }
+ } else {
+ ctx.ModuleErrorf("Super partition %s does set SuperImageProvider\n", superPartition.Name())
+ }
+ }
}
func (a *androidDevice) getFilesystemInfo(ctx android.ModuleContext, depName string) FilesystemInfo {