Add Ramdisk files to target_files.zip
The ramdisk files will be copied via the bootimg module deps of the
android_device.
This CL also fixes a bug where system in intermediates was using for
copy, instead of system/system
Bug: 385383524
Test: m out/soong/.intermediates/build/soong/fsgen/aosp_cf_x86_64_phone_generated_device/android_common/target_files.zip
reports fewer diffs now than the make-built target_files.zip
Change-Id: I47e29d0b32059c8f34c8d27580f62fca9f5636d0
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 6beb803..1af9af9 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -79,8 +79,8 @@
}
addDependencyIfDefined(a.partitionProps.Boot_partition_name)
- addDependencyIfDefined(a.partitionProps.Vendor_boot_partition_name)
addDependencyIfDefined(a.partitionProps.Init_boot_partition_name)
+ addDependencyIfDefined(a.partitionProps.Vendor_boot_partition_name)
addDependencyIfDefined(a.partitionProps.System_partition_name)
addDependencyIfDefined(a.partitionProps.System_ext_partition_name)
addDependencyIfDefined(a.partitionProps.Product_partition_name)
@@ -90,6 +90,7 @@
addDependencyIfDefined(a.partitionProps.System_dlkm_partition_name)
addDependencyIfDefined(a.partitionProps.Vendor_dlkm_partition_name)
addDependencyIfDefined(a.partitionProps.Odm_dlkm_partition_name)
+ addDependencyIfDefined(a.partitionProps.Recovery_partition_name)
for _, vbmetaPartition := range a.partitionProps.Vbmeta_partitions {
ctx.AddDependency(ctx.Module(), filesystemDepTag, vbmetaPartition)
}
@@ -99,6 +100,11 @@
a.buildTargetFilesZip(ctx)
}
+type targetFilesZipCopy struct {
+ srcModule *string
+ destSubdir string
+}
+
func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
targetFilesDir := android.PathForModuleOut(ctx, "target_files_dir")
targetFilesZip := android.PathForModuleOut(ctx, "target_files.zip")
@@ -106,26 +112,41 @@
builder := android.NewRuleBuilder(pctx, ctx)
builder.Command().Textf("rm -rf %s", targetFilesDir.String())
builder.Command().Textf("mkdir -p %s", targetFilesDir.String())
- partitionToSubdir := map[*string]string{
- a.partitionProps.System_partition_name: "SYSTEM",
- a.partitionProps.System_ext_partition_name: "SYSTEM_EXT",
- a.partitionProps.Product_partition_name: "PRODUCT",
- a.partitionProps.Vendor_partition_name: "VENDOR",
- a.partitionProps.Odm_partition_name: "ODM",
- a.partitionProps.System_dlkm_partition_name: "SYSTEM_DLKM",
- a.partitionProps.Vendor_dlkm_partition_name: "VENDOR_DLKM",
- a.partitionProps.Odm_dlkm_partition_name: "ODM_DLKM",
+ toCopy := []targetFilesZipCopy{
+ targetFilesZipCopy{a.partitionProps.System_partition_name, "SYSTEM"},
+ targetFilesZipCopy{a.partitionProps.System_ext_partition_name, "SYSTEM_EXT"},
+ targetFilesZipCopy{a.partitionProps.Product_partition_name, "PRODUCT"},
+ targetFilesZipCopy{a.partitionProps.Vendor_partition_name, "VENDOR"},
+ targetFilesZipCopy{a.partitionProps.Odm_partition_name, "ODM"},
+ targetFilesZipCopy{a.partitionProps.System_dlkm_partition_name, "SYSTEM_DLKM"},
+ targetFilesZipCopy{a.partitionProps.Vendor_dlkm_partition_name, "VENDOR_DLKM"},
+ targetFilesZipCopy{a.partitionProps.Odm_dlkm_partition_name, "ODM_DLKM"},
+ targetFilesZipCopy{a.partitionProps.Init_boot_partition_name, "BOOT/RAMDISK"},
+ targetFilesZipCopy{a.partitionProps.Init_boot_partition_name, "INIT_BOOT/RAMDISK"},
+ targetFilesZipCopy{a.partitionProps.Vendor_boot_partition_name, "VENDOR_BOOT/RAMDISK"},
}
- for partition, subdir := range partitionToSubdir {
- if partition == nil {
+ // TODO: Handle cases where recovery files are copied to BOOT/ or RECOVERY/
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=6211-6219?q=core%2FMakefile&ss=android%2Fplatform%2Fsuperproject%2Fmain
+ if ctx.DeviceConfig().BoardMoveRecoveryResourcesToVendorBoot() {
+ toCopy = append(toCopy, targetFilesZipCopy{a.partitionProps.Recovery_partition_name, "VENDOR_BOOT/RAMDISK"})
+ }
+
+ for _, zipCopy := range toCopy {
+ if zipCopy.srcModule == nil {
continue
}
- fsInfo := a.getFilesystemInfo(ctx, *partition)
+ fsInfo := a.getFilesystemInfo(ctx, *zipCopy.srcModule)
+ subdir := zipCopy.destSubdir
+ rootDirString := fsInfo.RootDir.String()
+ if subdir == "SYSTEM" {
+ rootDirString = rootDirString + "/system"
+ }
builder.Command().Textf("mkdir -p %s/%s", targetFilesDir.String(), subdir)
builder.Command().
BuiltTool("acp").
- Textf("-rd %s/. %s/%s", fsInfo.RootDir, targetFilesDir, subdir).
+ Textf("-rd %s/. %s/%s", rootDirString, targetFilesDir, subdir).
Implicit(fsInfo.Output) // so that the staging dir is built
+
}
builder.Command().
BuiltTool("soong_zip").