Create super_empty.img using Soong
The build rule for this .img file will be created in super_image. It
will use the a minimized file returned by `buildMiscInfo` without any
partition information. This file will be disted in target_files.zip
Bug: 390192334
Test: Verified that this file is bit-identical between make and soong
for aosp_cf_x86_64_phone
Change-Id: I9238d67d2ca8739064509a858d5251f2641896e9
diff --git a/android/variable.go b/android/variable.go
index 853d8ef..2134763 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -654,6 +654,7 @@
ProductUseDynamicPartitions bool `json:",omitempty"`
ProductRetrofitDynamicPartitions bool `json:",omitempty"`
ProductBuildSuperPartition bool `json:",omitempty"`
+ BuildingSuperEmptyImage bool `json:",omitempty"`
BoardSuperPartitionSize string `json:",omitempty"`
BoardSuperPartitionMetadataDevice string `json:",omitempty"`
BoardSuperPartitionBlockDevices []string `json:",omitempty"`
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 22ad7cf..45a8620 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -623,6 +623,10 @@
builder.Command().Textf("cp ").Input(info.SubImageInfo[partition].MapFile).Textf(" %s/IMAGES/", targetFilesDir.String())
}
}
+ // super_empty.img
+ if info.SuperEmptyImage != nil {
+ builder.Command().Textf("cp ").Input(info.SuperEmptyImage).Textf(" %s/IMAGES/", targetFilesDir.String())
+ }
} else {
ctx.ModuleErrorf("Super partition %s does set SuperImageProvider\n", superPartition.Name())
}
diff --git a/filesystem/super_image.go b/filesystem/super_image.go
index 5108025..8e2b532 100644
--- a/filesystem/super_image.go
+++ b/filesystem/super_image.go
@@ -80,6 +80,8 @@
}
// Whether the super image will be disted in the update package
Super_image_in_update_package *bool
+ // Whether a super_empty.img should be created
+ Create_super_empty *bool
}
type PartitionGroupsInfo struct {
@@ -118,6 +120,8 @@
SubImageInfo map[string]FilesystemInfo
DynamicPartitionsInfo android.Path
+
+ SuperEmptyImage android.Path
}
var SuperImageProvider = blueprint.NewProvider[SuperImageInfo]()
@@ -163,7 +167,7 @@
}
func (s *superImage) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- miscInfo, deps, subImageInfos := s.buildMiscInfo(ctx)
+ miscInfo, deps, subImageInfos := s.buildMiscInfo(ctx, false)
builder := android.NewRuleBuilder(pctx, ctx)
output := android.PathForModuleOut(ctx, s.installFileName())
lpMake := ctx.Config().HostToolPath(ctx, "lpmake")
@@ -176,10 +180,27 @@
Implicits(deps).
Output(output)
builder.Build("build_super_image", fmt.Sprintf("Creating super image %s", s.BaseModuleName()))
+ var superEmptyImage android.WritablePath
+ if proptools.Bool(s.properties.Create_super_empty) {
+ superEmptyImageBuilder := android.NewRuleBuilder(pctx, ctx)
+ superEmptyImage = android.PathForModuleOut(ctx, "super_empty.img")
+ superEmptyMiscInfo, superEmptyDeps, _ := s.buildMiscInfo(ctx, true)
+ if superEmptyDeps != nil {
+ ctx.ModuleErrorf("TODO: Handle additional deps when building super_empty.img")
+ }
+ superEmptyImageBuilder.Command().Textf("PATH=%s:\\$PATH", lpMakeDir).
+ BuiltTool("build_super_image").
+ Text("-v").
+ Input(superEmptyMiscInfo).
+ Implicit(lpMake).
+ Output(superEmptyImage)
+ superEmptyImageBuilder.Build("build_super_empty_image", fmt.Sprintf("Creating super empty image %s", s.BaseModuleName()))
+ }
android.SetProvider(ctx, SuperImageProvider, SuperImageInfo{
SuperImage: output,
SubImageInfo: subImageInfos,
DynamicPartitionsInfo: s.generateDynamicPartitionsInfo(ctx),
+ SuperEmptyImage: superEmptyImage,
})
ctx.SetOutputFiles([]android.Path{output}, "")
ctx.CheckbuildFile(output)
@@ -191,7 +212,7 @@
return "super.img"
}
-func (s *superImage) buildMiscInfo(ctx android.ModuleContext) (android.Path, android.Paths, map[string]FilesystemInfo) {
+func (s *superImage) buildMiscInfo(ctx android.ModuleContext, superEmpty bool) (android.Path, android.Paths, map[string]FilesystemInfo) {
var miscInfoString strings.Builder
partitionList := s.dumpDynamicPartitionInfo(ctx, &miscInfoString)
addStr := func(name string, value string) {
@@ -201,6 +222,11 @@
miscInfoString.WriteRune('\n')
}
addStr("ab_update", strconv.FormatBool(proptools.Bool(s.properties.Ab_update)))
+ if superEmpty {
+ miscInfo := android.PathForModuleOut(ctx, "misc_info_super_empty.txt")
+ android.WriteFileRule(ctx, miscInfo, miscInfoString.String())
+ return miscInfo, nil, nil
+ }
subImageInfo := make(map[string]FilesystemInfo)
var deps android.Paths
@@ -300,6 +326,9 @@
}
addStr("build_super_partition", "true")
+ if proptools.Bool(s.properties.Create_super_empty) {
+ addStr("build_super_empty_partition", "true")
+ }
addStr("use_dynamic_partitions", strconv.FormatBool(proptools.Bool(s.properties.Use_dynamic_partitions)))
if proptools.Bool(s.properties.Retrofit) {
addStr("dynamic_partition_retrofit", "true")
diff --git a/fsgen/super_img.go b/fsgen/super_img.go
index f564636..1d610f6 100644
--- a/fsgen/super_img.go
+++ b/fsgen/super_img.go
@@ -46,6 +46,7 @@
Retrofit: proptools.BoolPtr(partitionVars.ProductRetrofitDynamicPartitions),
Use_dynamic_partitions: proptools.BoolPtr(partitionVars.ProductUseDynamicPartitions),
Super_image_in_update_package: proptools.BoolPtr(partitionVars.BoardSuperImageInUpdatePackage),
+ Create_super_empty: proptools.BoolPtr(partitionVars.BuildingSuperEmptyImage),
}
if partitionVars.ProductVirtualAbOta {
superImageProps.Virtual_ab.Enable = proptools.BoolPtr(true)