diff options
author | 2025-03-11 19:48:17 -0700 | |
---|---|---|
committer | 2025-03-11 19:48:17 -0700 | |
commit | 30d6869676013ff6776891663138d1450a0a3f64 (patch) | |
tree | 2526392aadd1badbfaad7dfe9bcb97c84dbdea2f | |
parent | 8d2c52035a6ccb8e6e85b2ca59e68a14166f6b5c (diff) | |
parent | 5a8f5eb89685db19666cbcc6647768708837e68e (diff) |
Merge "Create super_empty.img using Soong" into main am: c9854201c3 am: 5a8f5eb896
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3533444
Change-Id: Icf48a94542adf772c4f6eaa0e5f8252c6873460f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | android/variable.go | 1 | ||||
-rw-r--r-- | filesystem/android_device.go | 4 | ||||
-rw-r--r-- | filesystem/super_image.go | 33 | ||||
-rw-r--r-- | fsgen/super_img.go | 1 |
4 files changed, 37 insertions, 2 deletions
diff --git a/android/variable.go b/android/variable.go index da7c96dcf..3dba60736 100644 --- a/android/variable.go +++ b/android/variable.go @@ -656,6 +656,7 @@ type PartitionVariables struct { 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 22ad7cf7b..45a8620c5 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -623,6 +623,10 @@ func (a *androidDevice) copyImagesToTargetZip(ctx android.ModuleContext, builder 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 51080258c..8e2b532a6 100644 --- a/filesystem/super_image.go +++ b/filesystem/super_image.go @@ -80,6 +80,8 @@ type SuperImageProperties struct { } // 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 @@ type SuperImageInfo struct { SubImageInfo map[string]FilesystemInfo DynamicPartitionsInfo android.Path + + SuperEmptyImage android.Path } var SuperImageProvider = blueprint.NewProvider[SuperImageInfo]() @@ -163,7 +167,7 @@ func (s *superImage) DepsMutator(ctx android.BottomUpMutatorContext) { } 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 @@ func (s *superImage) GenerateAndroidBuildActions(ctx android.ModuleContext) { 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 @@ func (s *superImage) installFileName() string { 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 @@ func (s *superImage) buildMiscInfo(ctx android.ModuleContext) (android.Path, and 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 @@ func (s *superImage) dumpDynamicPartitionInfo(ctx android.ModuleContext, sb *str } 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 f5646365f..1d610f63c 100644 --- a/fsgen/super_img.go +++ b/fsgen/super_img.go @@ -46,6 +46,7 @@ func createSuperImage( 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) |