Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 1 | // Copyright (C) 2021 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 | |
| 15 | package filesystem |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "strconv" |
Jiyong Park | ac4076d | 2021-03-15 23:21:30 +0900 | [diff] [blame] | 20 | "strings" |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 21 | |
| 22 | "github.com/google/blueprint" |
| 23 | "github.com/google/blueprint/proptools" |
| 24 | |
| 25 | "android/soong/android" |
| 26 | ) |
| 27 | |
| 28 | func init() { |
Cole Faust | f2a6e8b | 2024-11-14 10:54:48 -0800 | [diff] [blame] | 29 | android.RegisterModuleType("bootimg", BootimgFactory) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | type bootimg struct { |
| 33 | android.ModuleBase |
| 34 | |
Cole Faust | f2a6e8b | 2024-11-14 10:54:48 -0800 | [diff] [blame] | 35 | properties BootimgProperties |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 36 | |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 37 | output android.Path |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 38 | installDir android.InstallPath |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 39 | |
| 40 | bootImageType bootImageType |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 41 | } |
| 42 | |
Cole Faust | f2a6e8b | 2024-11-14 10:54:48 -0800 | [diff] [blame] | 43 | type BootimgProperties struct { |
Jiyong Park | 1f55dbd | 2021-02-15 17:57:35 +0900 | [diff] [blame] | 44 | // Set the name of the output. Defaults to <module_name>.img. |
| 45 | Stem *string |
| 46 | |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 47 | // Path to the linux kernel prebuilt file |
| 48 | Kernel_prebuilt *string `android:"arch_variant,path"` |
| 49 | |
| 50 | // Filesystem module that is used as ramdisk |
| 51 | Ramdisk_module *string |
| 52 | |
| 53 | // Path to the device tree blob (DTB) prebuilt file to add to this boot image |
| 54 | Dtb_prebuilt *string `android:"arch_variant,path"` |
| 55 | |
| 56 | // Header version number. Must be set to one of the version numbers that are currently |
| 57 | // supported. Refer to |
| 58 | // https://source.android.com/devices/bootloader/boot-image-header |
| 59 | Header_version *string |
| 60 | |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 61 | // Determines the specific type of boot image this module is building. Can be boot, |
| 62 | // vendor_boot or init_boot. Defaults to boot. |
| 63 | // Refer to https://source.android.com/devices/bootloader/partitions/vendor-boot-partitions |
| 64 | // for vendor_boot. |
| 65 | // Refer to https://source.android.com/docs/core/architecture/partitions/generic-boot for |
| 66 | // init_boot. |
| 67 | Boot_image_type *string |
Jihoon Kang | 95eb1da | 2024-11-19 20:55:20 +0000 | [diff] [blame] | 68 | |
Jiyong Park | 16e77a9 | 2021-08-30 18:43:19 +0900 | [diff] [blame] | 69 | // Optional kernel commandline arguments |
| 70 | Cmdline []string `android:"arch_variant"` |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 71 | |
Jiyong Park | 81aea9a | 2021-03-05 18:58:29 +0900 | [diff] [blame] | 72 | // File that contains bootconfig parameters. This can be set only when `vendor_boot` is true |
| 73 | // and `header_version` is greater than or equal to 4. |
| 74 | Bootconfig *string `android:"arch_variant,path"` |
| 75 | |
Cole Faust | 26bdac5 | 2024-11-19 13:37:53 -0800 | [diff] [blame] | 76 | // The size of the partition on the device. It will be a build error if this built partition |
| 77 | // image exceeds this size. |
| 78 | Partition_size *int64 |
| 79 | |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 80 | // When set to true, sign the image with avbtool. Default is false. |
| 81 | Use_avb *bool |
| 82 | |
| 83 | // Name of the partition stored in vbmeta desc. Defaults to the name of this module. |
| 84 | Partition_name *string |
| 85 | |
| 86 | // Path to the private key that avbtool will use to sign this filesystem image. |
| 87 | // TODO(jiyong): allow apex_key to be specified here |
Cole Faust | 65cb40a | 2024-10-21 15:41:42 -0700 | [diff] [blame] | 88 | Avb_private_key *string `android:"path_device_first"` |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 89 | |
| 90 | // Hash and signing algorithm for avbtool. Default is SHA256_RSA4096. |
| 91 | Avb_algorithm *string |
| 92 | } |
| 93 | |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 94 | type bootImageType int |
| 95 | |
| 96 | const ( |
| 97 | unsupported bootImageType = iota |
| 98 | boot |
| 99 | vendorBoot |
| 100 | initBoot |
| 101 | ) |
| 102 | |
| 103 | func toBootImageType(ctx android.ModuleContext, bootImageType string) bootImageType { |
| 104 | switch bootImageType { |
| 105 | case "boot": |
| 106 | return boot |
| 107 | case "vendor_boot": |
| 108 | return vendorBoot |
| 109 | case "init_boot": |
| 110 | return initBoot |
| 111 | default: |
| 112 | ctx.ModuleErrorf("Unknown boot_image_type %s. Must be one of \"boot\", \"vendor_boot\", or \"init_boot\"", bootImageType) |
| 113 | } |
| 114 | return unsupported |
| 115 | } |
| 116 | |
| 117 | func (b bootImageType) isBoot() bool { |
| 118 | return b == boot |
| 119 | } |
| 120 | |
| 121 | func (b bootImageType) isVendorBoot() bool { |
| 122 | return b == vendorBoot |
| 123 | } |
| 124 | |
| 125 | func (b bootImageType) isInitBoot() bool { |
| 126 | return b == initBoot |
| 127 | } |
| 128 | |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 129 | // bootimg is the image for the boot partition. It consists of header, kernel, ramdisk, and dtb. |
Cole Faust | f2a6e8b | 2024-11-14 10:54:48 -0800 | [diff] [blame] | 130 | func BootimgFactory() android.Module { |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 131 | module := &bootimg{} |
| 132 | module.AddProperties(&module.properties) |
| 133 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 134 | return module |
| 135 | } |
| 136 | |
| 137 | type bootimgDep struct { |
| 138 | blueprint.BaseDependencyTag |
| 139 | kind string |
| 140 | } |
| 141 | |
| 142 | var bootimgRamdiskDep = bootimgDep{kind: "ramdisk"} |
| 143 | |
| 144 | func (b *bootimg) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 145 | ramdisk := proptools.String(b.properties.Ramdisk_module) |
| 146 | if ramdisk != "" { |
| 147 | ctx.AddDependency(ctx.Module(), bootimgRamdiskDep, ramdisk) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func (b *bootimg) installFileName() string { |
Jiyong Park | 1f55dbd | 2021-02-15 17:57:35 +0900 | [diff] [blame] | 152 | return proptools.StringDefault(b.properties.Stem, b.BaseModuleName()+".img") |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | func (b *bootimg) partitionName() string { |
| 156 | return proptools.StringDefault(b.properties.Partition_name, b.BaseModuleName()) |
| 157 | } |
| 158 | |
| 159 | func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 160 | b.bootImageType = toBootImageType(ctx, proptools.StringDefault(b.properties.Boot_image_type, "boot")) |
| 161 | unsignedOutput := b.buildBootImage(ctx) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 162 | |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 163 | output := unsignedOutput |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 164 | if proptools.Bool(b.properties.Use_avb) { |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 165 | output = b.signImage(ctx, unsignedOutput) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | b.installDir = android.PathForModuleInstall(ctx, "etc") |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 169 | ctx.InstallFile(b.installDir, b.installFileName(), output) |
mrziwang | 555d133 | 2024-06-07 11:15:33 -0700 | [diff] [blame] | 170 | |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 171 | ctx.SetOutputFiles([]android.Path{output}, "") |
| 172 | b.output = output |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 173 | } |
| 174 | |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 175 | func (b *bootimg) buildBootImage(ctx android.ModuleContext) android.Path { |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 176 | output := android.PathForModuleOut(ctx, "unsigned", b.installFileName()) |
Jiyong Park | 1f55dbd | 2021-02-15 17:57:35 +0900 | [diff] [blame] | 177 | |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 178 | builder := android.NewRuleBuilder(pctx, ctx) |
| 179 | cmd := builder.Command().BuiltTool("mkbootimg") |
| 180 | |
Jiyong Park | 4bbd6cf | 2021-02-18 22:28:31 +0900 | [diff] [blame] | 181 | kernel := proptools.String(b.properties.Kernel_prebuilt) |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 182 | if b.bootImageType.isVendorBoot() && kernel != "" { |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 183 | ctx.PropertyErrorf("kernel_prebuilt", "vendor_boot partition can't have kernel") |
| 184 | return output |
| 185 | } |
Jihoon Kang | 95eb1da | 2024-11-19 20:55:20 +0000 | [diff] [blame] | 186 | |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 187 | if b.bootImageType.isBoot() && kernel == "" { |
Jiyong Park | 4bbd6cf | 2021-02-18 22:28:31 +0900 | [diff] [blame] | 188 | ctx.PropertyErrorf("kernel_prebuilt", "boot partition must have kernel") |
| 189 | return output |
| 190 | } |
| 191 | if kernel != "" { |
| 192 | cmd.FlagWithInput("--kernel ", android.PathForModuleSrc(ctx, kernel)) |
| 193 | } |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 194 | |
Jihoon Kang | 95eb1da | 2024-11-19 20:55:20 +0000 | [diff] [blame] | 195 | // These arguments are passed for boot.img and init_boot.img generation |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 196 | if b.bootImageType.isBoot() || b.bootImageType.isInitBoot() { |
Cole Faust | 1c9c335 | 2024-11-19 11:34:44 -0800 | [diff] [blame] | 197 | cmd.FlagWithArg("--os_version ", ctx.Config().PlatformVersionLastStable()) |
| 198 | cmd.FlagWithArg("--os_patch_level ", ctx.Config().PlatformSecurityPatch()) |
| 199 | } |
| 200 | |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 201 | dtbName := proptools.String(b.properties.Dtb_prebuilt) |
Jiyong Park | 393ebfc | 2022-01-06 14:28:53 +0900 | [diff] [blame] | 202 | if dtbName != "" { |
| 203 | dtb := android.PathForModuleSrc(ctx, dtbName) |
| 204 | cmd.FlagWithInput("--dtb ", dtb) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 205 | } |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 206 | |
Jiyong Park | 16e77a9 | 2021-08-30 18:43:19 +0900 | [diff] [blame] | 207 | cmdline := strings.Join(b.properties.Cmdline, " ") |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 208 | if cmdline != "" { |
Jiyong Park | 4bbd6cf | 2021-02-18 22:28:31 +0900 | [diff] [blame] | 209 | flag := "--cmdline " |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 210 | if b.bootImageType.isVendorBoot() { |
Jiyong Park | 4bbd6cf | 2021-02-18 22:28:31 +0900 | [diff] [blame] | 211 | flag = "--vendor_cmdline " |
| 212 | } |
Jooyung Han | 32cddd0 | 2021-03-08 20:54:16 +0900 | [diff] [blame] | 213 | cmd.FlagWithArg(flag, proptools.ShellEscapeIncludingSpaces(cmdline)) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | headerVersion := proptools.String(b.properties.Header_version) |
| 217 | if headerVersion == "" { |
| 218 | ctx.PropertyErrorf("header_version", "must be set") |
| 219 | return output |
| 220 | } |
| 221 | verNum, err := strconv.Atoi(headerVersion) |
| 222 | if err != nil { |
| 223 | ctx.PropertyErrorf("header_version", "%q is not a number", headerVersion) |
| 224 | return output |
| 225 | } |
| 226 | if verNum < 3 { |
| 227 | ctx.PropertyErrorf("header_version", "must be 3 or higher for vendor_boot") |
| 228 | return output |
| 229 | } |
| 230 | cmd.FlagWithArg("--header_version ", headerVersion) |
| 231 | |
| 232 | ramdiskName := proptools.String(b.properties.Ramdisk_module) |
Jiyong Park | 393ebfc | 2022-01-06 14:28:53 +0900 | [diff] [blame] | 233 | if ramdiskName != "" { |
| 234 | ramdisk := ctx.GetDirectDepWithTag(ramdiskName, bootimgRamdiskDep) |
| 235 | if filesystem, ok := ramdisk.(*filesystem); ok { |
| 236 | flag := "--ramdisk " |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 237 | if b.bootImageType.isVendorBoot() { |
Jiyong Park | 393ebfc | 2022-01-06 14:28:53 +0900 | [diff] [blame] | 238 | flag = "--vendor_ramdisk " |
| 239 | } |
| 240 | cmd.FlagWithInput(flag, filesystem.OutputPath()) |
| 241 | } else { |
| 242 | ctx.PropertyErrorf("ramdisk", "%q is not android_filesystem module", ramdisk.Name()) |
| 243 | return output |
Jiyong Park | 4bbd6cf | 2021-02-18 22:28:31 +0900 | [diff] [blame] | 244 | } |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 245 | } |
| 246 | |
Jiyong Park | 81aea9a | 2021-03-05 18:58:29 +0900 | [diff] [blame] | 247 | bootconfig := proptools.String(b.properties.Bootconfig) |
| 248 | if bootconfig != "" { |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 249 | if !b.bootImageType.isVendorBoot() { |
Jiyong Park | 81aea9a | 2021-03-05 18:58:29 +0900 | [diff] [blame] | 250 | ctx.PropertyErrorf("bootconfig", "requires vendor_boot: true") |
| 251 | return output |
| 252 | } |
| 253 | if verNum < 4 { |
| 254 | ctx.PropertyErrorf("bootconfig", "requires header_version: 4 or later") |
| 255 | return output |
| 256 | } |
| 257 | cmd.FlagWithInput("--vendor_bootconfig ", android.PathForModuleSrc(ctx, bootconfig)) |
| 258 | } |
| 259 | |
Jihoon Kang | 95eb1da | 2024-11-19 20:55:20 +0000 | [diff] [blame] | 260 | // Output flag for boot.img and init_boot.img |
Jiyong Park | 4bbd6cf | 2021-02-18 22:28:31 +0900 | [diff] [blame] | 261 | flag := "--output " |
Jihoon Kang | 96fdba9 | 2024-11-19 22:25:36 +0000 | [diff] [blame] | 262 | if b.bootImageType.isVendorBoot() { |
Jiyong Park | 4bbd6cf | 2021-02-18 22:28:31 +0900 | [diff] [blame] | 263 | flag = "--vendor_boot " |
| 264 | } |
| 265 | cmd.FlagWithOutput(flag, output) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 266 | |
Cole Faust | 26bdac5 | 2024-11-19 13:37:53 -0800 | [diff] [blame] | 267 | if b.properties.Partition_size != nil { |
| 268 | assertMaxImageSize(builder, output, *b.properties.Partition_size, proptools.Bool(b.properties.Use_avb)) |
| 269 | } |
| 270 | |
Jiyong Park | 4bbd6cf | 2021-02-18 22:28:31 +0900 | [diff] [blame] | 271 | builder.Build("build_bootimg", fmt.Sprintf("Creating %s", b.BaseModuleName())) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 272 | return output |
| 273 | } |
| 274 | |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 275 | func (b *bootimg) signImage(ctx android.ModuleContext, unsignedImage android.Path) android.Path { |
Jiyong Park | ac4076d | 2021-03-15 23:21:30 +0900 | [diff] [blame] | 276 | propFile, toolDeps := b.buildPropFile(ctx) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 277 | |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 278 | output := android.PathForModuleOut(ctx, b.installFileName()) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 279 | builder := android.NewRuleBuilder(pctx, ctx) |
Jiyong Park | 1f55dbd | 2021-02-15 17:57:35 +0900 | [diff] [blame] | 280 | builder.Command().Text("cp").Input(unsignedImage).Output(output) |
Jiyong Park | ac4076d | 2021-03-15 23:21:30 +0900 | [diff] [blame] | 281 | builder.Command().BuiltTool("verity_utils"). |
| 282 | Input(propFile). |
| 283 | Implicits(toolDeps). |
| 284 | Output(output) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 285 | |
| 286 | builder.Build("sign_bootimg", fmt.Sprintf("Signing %s", b.BaseModuleName())) |
Jiyong Park | 1f55dbd | 2021-02-15 17:57:35 +0900 | [diff] [blame] | 287 | return output |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 288 | } |
| 289 | |
Jooyung Han | 65f402b | 2022-04-21 14:24:04 +0900 | [diff] [blame] | 290 | // Calculates avb_salt from some input for deterministic output. |
| 291 | func (b *bootimg) salt() string { |
| 292 | var input []string |
| 293 | input = append(input, b.properties.Cmdline...) |
| 294 | input = append(input, proptools.StringDefault(b.properties.Partition_name, b.Name())) |
| 295 | input = append(input, proptools.String(b.properties.Header_version)) |
| 296 | return sha1sum(input) |
| 297 | } |
| 298 | |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 299 | func (b *bootimg) buildPropFile(ctx android.ModuleContext) (android.Path, android.Paths) { |
Jiyong Park | ac4076d | 2021-03-15 23:21:30 +0900 | [diff] [blame] | 300 | var sb strings.Builder |
| 301 | var deps android.Paths |
| 302 | addStr := func(name string, value string) { |
| 303 | fmt.Fprintf(&sb, "%s=%s\n", name, value) |
| 304 | } |
| 305 | addPath := func(name string, path android.Path) { |
| 306 | addStr(name, path.String()) |
| 307 | deps = append(deps, path) |
| 308 | } |
| 309 | |
| 310 | addStr("avb_hash_enable", "true") |
| 311 | addPath("avb_avbtool", ctx.Config().HostToolPath(ctx, "avbtool")) |
| 312 | algorithm := proptools.StringDefault(b.properties.Avb_algorithm, "SHA256_RSA4096") |
| 313 | addStr("avb_algorithm", algorithm) |
| 314 | key := android.PathForModuleSrc(ctx, proptools.String(b.properties.Avb_private_key)) |
| 315 | addPath("avb_key_path", key) |
| 316 | addStr("avb_add_hash_footer_args", "") // TODO(jiyong): add --rollback_index |
| 317 | partitionName := proptools.StringDefault(b.properties.Partition_name, b.Name()) |
| 318 | addStr("partition_name", partitionName) |
Jooyung Han | 65f402b | 2022-04-21 14:24:04 +0900 | [diff] [blame] | 319 | addStr("avb_salt", b.salt()) |
Jiyong Park | ac4076d | 2021-03-15 23:21:30 +0900 | [diff] [blame] | 320 | |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 321 | propFile := android.PathForModuleOut(ctx, "prop") |
Jiyong Park | ac4076d | 2021-03-15 23:21:30 +0900 | [diff] [blame] | 322 | android.WriteFileRule(ctx, propFile, sb.String()) |
| 323 | return propFile, deps |
| 324 | } |
| 325 | |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 326 | var _ android.AndroidMkEntriesProvider = (*bootimg)(nil) |
| 327 | |
| 328 | // Implements android.AndroidMkEntriesProvider |
| 329 | func (b *bootimg) AndroidMkEntries() []android.AndroidMkEntries { |
| 330 | return []android.AndroidMkEntries{android.AndroidMkEntries{ |
| 331 | Class: "ETC", |
| 332 | OutputFile: android.OptionalPathForPath(b.output), |
| 333 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 334 | func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | c68db4b | 2021-11-11 18:59:15 -0800 | [diff] [blame] | 335 | entries.SetString("LOCAL_MODULE_PATH", b.installDir.String()) |
Jiyong Park | 1f7b93e | 2021-02-01 21:38:11 +0900 | [diff] [blame] | 336 | entries.SetString("LOCAL_INSTALLED_MODULE_STEM", b.installFileName()) |
| 337 | }, |
| 338 | }, |
| 339 | }} |
| 340 | } |
| 341 | |
| 342 | var _ Filesystem = (*bootimg)(nil) |
| 343 | |
| 344 | func (b *bootimg) OutputPath() android.Path { |
| 345 | return b.output |
| 346 | } |
Jiyong Park | b0eb319 | 2021-03-09 20:29:07 +0900 | [diff] [blame] | 347 | |
Jiyong Park | 972e06c | 2021-03-15 23:32:49 +0900 | [diff] [blame] | 348 | func (b *bootimg) SignedOutputPath() android.Path { |
| 349 | if proptools.Bool(b.properties.Use_avb) { |
| 350 | return b.OutputPath() |
| 351 | } |
| 352 | return nil |
| 353 | } |