Revert "Add super.img to android_device"
This reverts commit 7724344371e60245c1ab00f75c213712e0e2036d.
Reason for revert: <Reason for revert: Dorid monitor: Likely culprit for b/388955493 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.>
Change-Id: I10d4decd8e419c8ab2b353141b5dd9190788c8e9
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index ae7755f..4b615bc 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -24,8 +24,6 @@
)
type PartitionNameProperties struct {
- // Name of the super partition filesystem module
- Super_partition_name *string
// Name of the boot partition filesystem module
Boot_partition_name *string
// Name of the vendor boot partition filesystem module
@@ -83,11 +81,6 @@
blueprint.BaseDependencyTag
}
-type superPartitionDepTagType struct {
- blueprint.BaseDependencyTag
-}
-
-var superPartitionDepTag superPartitionDepTagType
var filesystemDepTag partitionDepTagType
func (a *androidDevice) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -97,9 +90,6 @@
}
}
- if a.partitionProps.Super_partition_name != nil {
- ctx.AddDependency(ctx.Module(), superPartitionDepTag, *a.partitionProps.Super_partition_name)
- }
addDependencyIfDefined(a.partitionProps.Boot_partition_name)
addDependencyIfDefined(a.partitionProps.Init_boot_partition_name)
addDependencyIfDefined(a.partitionProps.Vendor_boot_partition_name)
@@ -139,44 +129,6 @@
func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.buildTargetFilesZip(ctx)
var deps []android.Path
- if proptools.String(a.partitionProps.Super_partition_name) != "" {
- superImage := ctx.GetDirectDepWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
- if info, ok := android.OtherModuleProvider(ctx, superImage, SuperImageProvider); ok {
- assertUnset := func(prop *string, propName string) {
- if prop != nil && *prop != "" {
- ctx.PropertyErrorf(propName, "Cannot be set because it's already part of the super image")
- }
- }
- for _, subPartitionType := range android.SortedKeys(info.SubImageInfo) {
- switch subPartitionType {
- case "system":
- assertUnset(a.partitionProps.System_partition_name, "system_partition_name")
- case "system_ext":
- assertUnset(a.partitionProps.System_ext_partition_name, "system_ext_partition_name")
- case "system_dlkm":
- assertUnset(a.partitionProps.System_dlkm_partition_name, "system_dlkm_partition_name")
- case "system_other":
- // TODO
- case "product":
- assertUnset(a.partitionProps.Product_partition_name, "product_partition_name")
- case "vendor":
- assertUnset(a.partitionProps.Vendor_partition_name, "vendor_partition_name")
- case "vendor_dlkm":
- assertUnset(a.partitionProps.Vendor_dlkm_partition_name, "vendor_dlkm_partition_name")
- case "odm":
- assertUnset(a.partitionProps.Odm_partition_name, "odm_partition_name")
- case "odm_dlkm":
- assertUnset(a.partitionProps.Odm_dlkm_partition_name, "odm_dlkm_partition_name")
- default:
- ctx.ModuleErrorf("Unsupported sub-partition of super partition: %q", subPartitionType)
- }
- }
-
- deps = append(deps, info.SuperImage)
- } else {
- ctx.ModuleErrorf("Expected super image dep to provide SuperImageProvider")
- }
- }
ctx.VisitDirectDepsWithTag(filesystemDepTag, func(m android.Module) {
imageOutput, ok := android.OtherModuleProvider(ctx, m, android.OutputFilesProvider)
if !ok {
diff --git a/filesystem/super_image.go b/filesystem/super_image.go
index cd99a28..0f8f614 100644
--- a/filesystem/super_image.go
+++ b/filesystem/super_image.go
@@ -21,7 +21,6 @@
"strings"
"android/soong/android"
-
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -89,17 +88,6 @@
Odm_dlkm_partition *string
}
-type SuperImageInfo struct {
- // The built super.img file, which contains the sub-partitions
- SuperImage android.Path
-
- // Mapping from the sub-partition type to its re-exported FileSystemInfo providers from the
- // sub-partitions.
- SubImageInfo map[string]FilesystemInfo
-}
-
-var SuperImageProvider = blueprint.NewProvider[SuperImageInfo]()
-
func SuperImageFactory() android.Module {
module := &superImage{}
module.AddProperties(&module.properties, &module.partitionProps)
@@ -111,12 +99,12 @@
blueprint.BaseDependencyTag
}
-var subImageDepTag superImageDepTagType
+var superImageDepTag superImageDepTagType
func (s *superImage) DepsMutator(ctx android.BottomUpMutatorContext) {
addDependencyIfDefined := func(dep *string) {
if dep != nil {
- ctx.AddDependency(ctx.Module(), subImageDepTag, proptools.String(dep))
+ ctx.AddDependency(ctx.Module(), superImageDepTag, proptools.String(dep))
}
}
@@ -132,7 +120,7 @@
}
func (s *superImage) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- miscInfo, deps, subImageInfos := s.buildMiscInfo(ctx)
+ miscInfo, deps := s.buildMiscInfo(ctx)
builder := android.NewRuleBuilder(pctx, ctx)
output := android.PathForModuleOut(ctx, s.installFileName())
lpMake := ctx.Config().HostToolPath(ctx, "lpmake")
@@ -145,19 +133,14 @@
Implicits(deps).
Output(output)
builder.Build("build_super_image", fmt.Sprintf("Creating super image %s", s.BaseModuleName()))
- android.SetProvider(ctx, SuperImageProvider, SuperImageInfo{
- SuperImage: output,
- SubImageInfo: subImageInfos,
- })
ctx.SetOutputFiles([]android.Path{output}, "")
- ctx.CheckbuildFile(output)
}
func (s *superImage) installFileName() string {
return s.BaseModuleName() + ".img"
}
-func (s *superImage) buildMiscInfo(ctx android.ModuleContext) (android.Path, android.Paths, map[string]FilesystemInfo) {
+func (s *superImage) buildMiscInfo(ctx android.ModuleContext) (android.Path, android.Paths) {
var miscInfoString strings.Builder
addStr := func(name string, value string) {
miscInfoString.WriteString(name)
@@ -181,11 +164,6 @@
addStr("super_"+groupInfo.Name+"_group_size", groupInfo.GroupSize)
addStr("super_"+groupInfo.Name+"_partition_list", strings.Join(groupInfo.PartitionList, " "))
}
- initialPartitionListLen := len(partitionList)
- partitionList = android.SortedUniqueStrings(partitionList)
- if len(partitionList) != initialPartitionListLen {
- ctx.ModuleErrorf("Duplicate partitions found in the partition_groups property")
- }
addStr("super_partition_groups", strings.Join(groups, " "))
addStr("dynamic_partition_list", strings.Join(partitionList, " "))
@@ -194,60 +172,65 @@
addStr("ab_update", strconv.FormatBool(proptools.Bool(s.properties.Ab_update)))
addStr("build_non_sparse_super_partition", strconv.FormatBool(!proptools.Bool(s.properties.Sparse)))
- subImageInfo := make(map[string]FilesystemInfo)
- var deps android.Paths
-
- handleSubPartition := func(partitionType string, name *string) {
- if proptools.String(name) == "" {
- ctx.ModuleErrorf("%s image listed in partition groups, but its module was not specified")
- return
+ partitionToImagePath := make(map[string]string)
+ nameToPartition := make(map[string]string)
+ var systemOtherPartitionNameNeeded string
+ addEntryToPartitionToName := func(p string, s *string) {
+ if proptools.String(s) != "" {
+ nameToPartition[*s] = p
}
- mod := ctx.GetDirectDepWithTag(*name, subImageDepTag)
- if mod == nil {
- ctx.ModuleErrorf("Could not get dep %q", *name)
- return
- }
- info, ok := android.OtherModuleProvider(ctx, mod, FilesystemProvider)
- if !ok {
- ctx.ModuleErrorf("Expected dep %q to provide FilesystemInfo", *name)
- return
- }
- addStr(partitionType+"_image", info.Output.String())
- deps = append(deps, info.Output)
- if _, ok := subImageInfo[partitionType]; ok {
- ctx.ModuleErrorf("Already set subimageInfo for %q", partitionType)
- }
- subImageInfo[partitionType] = info
}
// Build partitionToImagePath, because system partition may need system_other
// partition image path
for _, p := range partitionList {
+ if _, ok := nameToPartition[p]; ok {
+ continue
+ }
switch p {
case "system":
- handleSubPartition("system", s.partitionProps.System_partition)
- // TODO: add system_other to deps after it can be generated
- //getFsInfo("system_other", s.partitionProps.System_other_partition, &subImageInfo.System_other)
+ addEntryToPartitionToName(p, s.partitionProps.System_partition)
+ systemOtherPartitionNameNeeded = proptools.String(s.partitionProps.System_other_partition)
case "system_dlkm":
- handleSubPartition("system_dlkm", s.partitionProps.System_dlkm_partition)
+ addEntryToPartitionToName(p, s.partitionProps.System_dlkm_partition)
case "system_ext":
- handleSubPartition("system_ext", s.partitionProps.System_ext_partition)
+ addEntryToPartitionToName(p, s.partitionProps.System_ext_partition)
case "product":
- handleSubPartition("product", s.partitionProps.Product_partition)
+ addEntryToPartitionToName(p, s.partitionProps.Product_partition)
case "vendor":
- handleSubPartition("vendor", s.partitionProps.Vendor_partition)
+ addEntryToPartitionToName(p, s.partitionProps.Vendor_partition)
case "vendor_dlkm":
- handleSubPartition("vendor_dlkm", s.partitionProps.Vendor_dlkm_partition)
+ addEntryToPartitionToName(p, s.partitionProps.Vendor_dlkm_partition)
case "odm":
- handleSubPartition("odm", s.partitionProps.Odm_partition)
+ addEntryToPartitionToName(p, s.partitionProps.Odm_partition)
case "odm_dlkm":
- handleSubPartition("odm_dlkm", s.partitionProps.Odm_dlkm_partition)
+ addEntryToPartitionToName(p, s.partitionProps.Odm_dlkm_partition)
default:
- ctx.ModuleErrorf("partition %q is not a super image supported partition", p)
+ ctx.ModuleErrorf("current partition %s not a super image supported partition", p)
}
}
+ var deps android.Paths
+ ctx.VisitDirectDeps(func(m android.Module) {
+ if p, ok := nameToPartition[m.Name()]; ok {
+ if output, ok := android.OtherModuleProvider(ctx, m, android.OutputFilesProvider); ok {
+ partitionToImagePath[p] = output.DefaultOutputFiles[0].String()
+ deps = append(deps, output.DefaultOutputFiles[0])
+ }
+ } else if systemOtherPartitionNameNeeded != "" && m.Name() == systemOtherPartitionNameNeeded {
+ if output, ok := android.OtherModuleProvider(ctx, m, android.OutputFilesProvider); ok {
+ partitionToImagePath["system_other"] = output.DefaultOutputFiles[0].String()
+ // TODO: add system_other to deps after it can be generated
+ // deps = append(deps, output.DefaultOutputFiles[0])
+ }
+ }
+ })
+
+ for _, p := range android.SortedKeys(partitionToImagePath) {
+ addStr(p+"_image", partitionToImagePath[p])
+ }
+
miscInfo := android.PathForModuleOut(ctx, "misc_info.txt")
android.WriteFileRule(ctx, miscInfo, miscInfoString.String())
- return miscInfo, deps, subImageInfo
+ return miscInfo, deps
}