Add partition size check to boot partitions
Since android devices are partitioned at the factory and the partitions
can't be resized aftwards, make allows you to specify that partition
size and asserts that the contents don't exceed it. Soong also needed
this check.
Bug: 377562951
Test: Manually modified BOARD_BOOTIMAGE_PARTITION_SIZE to test the warning and error
Change-Id: I2368b350fb99c4055b14baa84b4964012f4934ef
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go
index ab91eb4..5aa60d2 100644
--- a/filesystem/bootimg.go
+++ b/filesystem/bootimg.go
@@ -67,6 +67,10 @@
// and `header_version` is greater than or equal to 4.
Bootconfig *string `android:"arch_variant,path"`
+ // The size of the partition on the device. It will be a build error if this built partition
+ // image exceeds this size.
+ Partition_size *int64
+
// When set to true, sign the image with avbtool. Default is false.
Use_avb *bool
@@ -216,6 +220,10 @@
}
cmd.FlagWithOutput(flag, output)
+ if b.properties.Partition_size != nil {
+ assertMaxImageSize(builder, output, *b.properties.Partition_size, proptools.Bool(b.properties.Use_avb))
+ }
+
builder.Build("build_bootimg", fmt.Sprintf("Creating %s", b.BaseModuleName()))
return output
}