summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2025-01-10 23:40:45 +0000
committer Spandan Das <spandandas@google.com> 2025-01-13 19:43:51 +0000
commit0036fa33250f7f527d2a49caaeda412e03440c55 (patch)
tree0545fafe5ec6571e8529c9ac38f40f69f35a50e2
parentf709844842d490e848c62b31e46350840bbc4106 (diff)
Copy boot*img files to IMAGES/ in target_files.zip
The following files will be added to the soong-built zip file after this CL 1. boot.img 2. init_boot.img 3. vendor_boot.img Implementation details - Refactor the IMAGES/ dir generation to `copyImagesToTargetZip` - Use VisitDirectDepsProxyWithTag(filesystemDepTag) to visit filesystem deps (e.g. system) and bootimg deps. - Set the Stem property in the autogenerated soong bootimg modules Test: Built the zip file locally and verified that boot*img files are copied (although they are not bit identical to the make equivalents) Bug: 388635097 Change-Id: Ia7138761146e93a268eecb9dc9bf4d579445980b
-rw-r--r--filesystem/android_device.go34
-rw-r--r--filesystem/bootimg.go2
-rw-r--r--fsgen/boot_imgs.go3
3 files changed, 27 insertions, 12 deletions
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 86f853cac..fe30a26df 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -208,17 +208,6 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
toCopy = append(toCopy, targetFilesZipCopy{a.partitionProps.Recovery_partition_name, "VENDOR_BOOT/RAMDISK"})
}
- // Create an IMAGES/ subdirectory
- builder.Command().Textf("mkdir -p %s/IMAGES/", targetFilesDir.String())
- if a.deviceProps.Bootloader != nil {
- builder.Command().Textf("cp ").Input(android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Bootloader))).Textf(" %s/IMAGES/bootloader", targetFilesDir.String())
- }
- // Copy the vbmeta img files to IMAGES/
- for _, vbmetaPartition := range a.partitionProps.Vbmeta_partitions {
- vbmetaInfo, _ := android.OtherModuleProvider(ctx, ctx.GetDirectDepWithTag(vbmetaPartition, filesystemDepTag), vbmetaPartitionProvider)
- builder.Command().Textf("cp ").Input(vbmetaInfo.Output).Textf(" %s/IMAGES/", targetFilesDir.String())
- }
-
for _, zipCopy := range toCopy {
if zipCopy.srcModule == nil {
continue
@@ -239,7 +228,6 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
// 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("cp %s %s/IMAGES/", fsInfo.Output, targetFilesDir.String())
}
// Copy cmdline, kernel etc. files of boot images
if a.partitionProps.Vendor_boot_partition_name != nil {
@@ -276,6 +264,8 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
builder.Command().Textf("cp %s %s/OTA/android-info.txt", android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Android_info)), targetFilesDir)
}
+ a.copyImagesToTargetZip(ctx, builder, targetFilesDir)
+
builder.Command().
BuiltTool("soong_zip").
Text("-d").
@@ -286,6 +276,26 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
builder.Build("target_files_"+ctx.ModuleName(), "Build target_files.zip")
}
+func (a *androidDevice) copyImagesToTargetZip(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir android.WritablePath) {
+ // Create an IMAGES/ subdirectory
+ builder.Command().Textf("mkdir -p %s/IMAGES", targetFilesDir.String())
+ if a.deviceProps.Bootloader != nil {
+ builder.Command().Textf("cp ").Input(android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Bootloader))).Textf(" %s/IMAGES/bootloader", targetFilesDir.String())
+ }
+ // 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 {
+ builder.Command().Textf("cp ").Input(info.Output).Textf(" %s/IMAGES/", targetFilesDir.String())
+ } else if info, ok := android.OtherModuleProvider(ctx, child, BootimgInfoProvider); 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())
+ } else {
+ ctx.ModuleErrorf("Module %s does not provide an .img file output for target_files.zip", child.Name())
+ }
+ })
+}
+
func (a *androidDevice) getFilesystemInfo(ctx android.ModuleContext, depName string) FilesystemInfo {
fsMod := ctx.GetDirectDepWithTag(depName, filesystemDepTag)
fsInfo, ok := android.OtherModuleProvider(ctx, fsMod, FilesystemProvider)
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go
index 0a3a1773f..803e98130 100644
--- a/filesystem/bootimg.go
+++ b/filesystem/bootimg.go
@@ -235,6 +235,7 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Kernel: b.getKernelPath(ctx),
Dtb: b.getDtbPath(ctx),
Bootconfig: b.getBootconfigPath(ctx),
+ Output: output,
})
}
@@ -245,6 +246,7 @@ type BootimgInfo struct {
Kernel android.Path
Dtb android.Path
Bootconfig android.Path
+ Output android.Path
}
func (b *bootimg) getKernelPath(ctx android.ModuleContext) android.Path {
diff --git a/fsgen/boot_imgs.go b/fsgen/boot_imgs.go
index 914d35beb..889a4c271 100644
--- a/fsgen/boot_imgs.go
+++ b/fsgen/boot_imgs.go
@@ -80,6 +80,7 @@ func createBootImage(ctx android.LoadHookContext, dtbImg dtbImg) bool {
Security_patch: securityPatch,
Dtb_prebuilt: dtbPrebuilt,
Cmdline: cmdline,
+ Stem: proptools.StringPtr("boot.img"),
},
&struct {
Name *string
@@ -133,6 +134,7 @@ func createVendorBootImage(ctx android.LoadHookContext, dtbImg dtbImg) bool {
Dtb_prebuilt: dtbPrebuilt,
Cmdline: cmdline,
Bootconfig: vendorBootConfigImg,
+ Stem: proptools.StringPtr("vendor_boot.img"),
},
&struct {
Name *string
@@ -180,6 +182,7 @@ func createInitBootImage(ctx android.LoadHookContext) bool {
Avb_private_key: avbInfo.avbkeyFilegroup,
Avb_rollback_index: avbInfo.avbRollbackIndex,
Avb_algorithm: avbInfo.avbAlgorithm,
+ Stem: proptools.StringPtr("init_boot.img"),
},
&struct {
Name *string