blob: a36f6144423cdf6440309155ca1b72bc0b2fe522 [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
30func createSuperImage(ctx android.LoadHookContext, partitions []string, partitionVars android.PartitionVariables) {
31 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
62 partitionNameProps := &filesystem.SuperImagePartitionNameProperties{}
63 if android.InList("system", partitions) {
64 partitionNameProps.System_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system"))
65 }
66 if android.InList("system_ext", partitions) {
67 partitionNameProps.System_ext_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_ext"))
68 }
69 if android.InList("system_dlkm", partitions) {
70 partitionNameProps.System_dlkm_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_dlkm"))
71 }
72 if android.InList("system_other", partitions) {
73 partitionNameProps.System_other_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_other"))
74 }
75 if android.InList("product", partitions) {
76 partitionNameProps.Product_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "product"))
77 }
78 if android.InList("vendor", partitions) {
79 partitionNameProps.Vendor_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "vendor"))
80 }
81 if android.InList("vendor_dlkm", partitions) {
82 partitionNameProps.Vendor_dlkm_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "vendor_dlkm"))
83 }
84 if android.InList("odm", partitions) {
85 partitionNameProps.Odm_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "odm"))
86 }
87 if android.InList("odm_dlkm", partitions) {
88 partitionNameProps.Odm_dlkm_partition = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "odm_dlkm"))
89 }
90
91 ctx.CreateModule(filesystem.SuperImageFactory, baseProps, superImageProps, partitionNameProps)
92}