blob: 5994fb6500284257f03f6f2c29c83c20110be1f5 [file] [log] [blame]
mrziwang79730d42024-12-02 22:13:59 -08001// Copyright (C) 2024 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package fsgen
16
17import (
18 "strconv"
19
20 "android/soong/android"
21 "android/soong/filesystem"
Jihoon Kang1259eff2025-01-09 22:11:03 +000022
mrziwang79730d42024-12-02 22:13:59 -080023 "github.com/google/blueprint/proptools"
24)
25
26func buildingSuperImage(partitionVars android.PartitionVariables) bool {
27 return partitionVars.ProductBuildSuperPartition
28}
29
Cole Faust2bdc5e52025-01-10 10:29:36 -080030func createSuperImage(ctx android.LoadHookContext, partitions []string, partitionVars android.PartitionVariables) []string {
mrziwang79730d42024-12-02 22:13:59 -080031 baseProps := &struct {
32 Name *string
33 }{
Jihoon Kang1259eff2025-01-09 22:11:03 +000034 Name: proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "super")),
mrziwang79730d42024-12-02 22:13:59 -080035 }
36
37 superImageProps := &filesystem.SuperImageProperties{
38 Metadata_device: proptools.StringPtr(partitionVars.BoardSuperPartitionMetadataDevice),
mrziwangf3c8ddf2024-12-05 17:15:11 -080039 Block_devices: partitionVars.BoardSuperPartitionBlockDevices,
mrziwang79730d42024-12-02 22:13:59 -080040 Ab_update: proptools.BoolPtr(partitionVars.AbOtaUpdater),
41 Retrofit: proptools.BoolPtr(partitionVars.ProductRetrofitDynamicPartitions),
42 Virtual_ab: proptools.BoolPtr(partitionVars.ProductVirtualAbOta),
43 Virtual_ab_retrofit: proptools.BoolPtr(partitionVars.ProductVirtualAbOtaRetrofit),
44 Use_dynamic_partitions: proptools.BoolPtr(partitionVars.ProductUseDynamicPartitions),
45 }
46 size, _ := strconv.ParseInt(partitionVars.BoardSuperPartitionSize, 10, 64)
47 superImageProps.Size = proptools.Int64Ptr(size)
48 sparse := !partitionVars.TargetUserimagesSparseExtDisabled && !partitionVars.TargetUserimagesSparseF2fsDisabled
49 superImageProps.Sparse = proptools.BoolPtr(sparse)
50
51 var partitionGroupsInfo []filesystem.PartitionGroupsInfo
52 for _, groupName := range android.SortedKeys(partitionVars.BoardSuperPartitionGroups) {
53 info := filesystem.PartitionGroupsInfo{
54 Name: groupName,
55 GroupSize: partitionVars.BoardSuperPartitionGroups[groupName].GroupSize,
56 PartitionList: partitionVars.BoardSuperPartitionGroups[groupName].PartitionList,
57 }
58 partitionGroupsInfo = append(partitionGroupsInfo, info)
59 }
60 superImageProps.Partition_groups = partitionGroupsInfo
61
Cole Faust2bdc5e52025-01-10 10:29:36 -080062 var superImageSubpartitions []string
mrziwang79730d42024-12-02 22:13:59 -080063 partitionNameProps := &filesystem.SuperImagePartitionNameProperties{}
64 if android.InList("system", partitions) {
65 partitionNameProps.System_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system"))
Cole Faust2bdc5e52025-01-10 10:29:36 -080066 superImageSubpartitions = append(superImageSubpartitions, "system")
mrziwang79730d42024-12-02 22:13:59 -080067 }
68 if android.InList("system_ext", partitions) {
69 partitionNameProps.System_ext_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_ext"))
Cole Faust2bdc5e52025-01-10 10:29:36 -080070 superImageSubpartitions = append(superImageSubpartitions, "system_ext")
mrziwang79730d42024-12-02 22:13:59 -080071 }
72 if android.InList("system_dlkm", partitions) {
73 partitionNameProps.System_dlkm_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_dlkm"))
Cole Faust2bdc5e52025-01-10 10:29:36 -080074 superImageSubpartitions = append(superImageSubpartitions, "system_dlkm")
mrziwang79730d42024-12-02 22:13:59 -080075 }
76 if android.InList("system_other", partitions) {
77 partitionNameProps.System_other_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_other"))
Cole Faust2bdc5e52025-01-10 10:29:36 -080078 superImageSubpartitions = append(superImageSubpartitions, "system_other")
mrziwang79730d42024-12-02 22:13:59 -080079 }
80 if android.InList("product", partitions) {
81 partitionNameProps.Product_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "product"))
Cole Faust2bdc5e52025-01-10 10:29:36 -080082 superImageSubpartitions = append(superImageSubpartitions, "product")
mrziwang79730d42024-12-02 22:13:59 -080083 }
84 if android.InList("vendor", partitions) {
85 partitionNameProps.Vendor_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "vendor"))
Cole Faust2bdc5e52025-01-10 10:29:36 -080086 superImageSubpartitions = append(superImageSubpartitions, "vendor")
mrziwang79730d42024-12-02 22:13:59 -080087 }
88 if android.InList("vendor_dlkm", partitions) {
89 partitionNameProps.Vendor_dlkm_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "vendor_dlkm"))
Cole Faust2bdc5e52025-01-10 10:29:36 -080090 superImageSubpartitions = append(superImageSubpartitions, "vendor_dlkm")
mrziwang79730d42024-12-02 22:13:59 -080091 }
92 if android.InList("odm", partitions) {
93 partitionNameProps.Odm_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "odm"))
Cole Faust2bdc5e52025-01-10 10:29:36 -080094 superImageSubpartitions = append(superImageSubpartitions, "odm")
mrziwang79730d42024-12-02 22:13:59 -080095 }
96 if android.InList("odm_dlkm", partitions) {
97 partitionNameProps.Odm_dlkm_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "odm_dlkm"))
Cole Faust2bdc5e52025-01-10 10:29:36 -080098 superImageSubpartitions = append(superImageSubpartitions, "odm_dlkm")
mrziwang79730d42024-12-02 22:13:59 -080099 }
100
101 ctx.CreateModule(filesystem.SuperImageFactory, baseProps, superImageProps, partitionNameProps)
Cole Faust2bdc5e52025-01-10 10:29:36 -0800102 return superImageSubpartitions
mrziwang79730d42024-12-02 22:13:59 -0800103}