Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 1 | // 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 | |
| 15 | package filesystem |
| 16 | |
| 17 | import ( |
Spandan Das | 258c08f | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 18 | "strings" |
Cole Faust | b55a41c | 2025-01-09 16:53:58 -0800 | [diff] [blame^] | 19 | "sync/atomic" |
Spandan Das | 258c08f | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 20 | |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 21 | "android/soong/android" |
| 22 | |
| 23 | "github.com/google/blueprint" |
| 24 | "github.com/google/blueprint/proptools" |
| 25 | ) |
| 26 | |
| 27 | type PartitionNameProperties struct { |
Cole Faust | 7724344 | 2025-01-09 15:49:15 -0800 | [diff] [blame] | 28 | // Name of the super partition filesystem module |
| 29 | Super_partition_name *string |
Jihoon Kang | e7e3ec8 | 2025-01-02 21:29:14 +0000 | [diff] [blame] | 30 | // Name of the boot partition filesystem module |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 31 | Boot_partition_name *string |
Jihoon Kang | e7e3ec8 | 2025-01-02 21:29:14 +0000 | [diff] [blame] | 32 | // Name of the vendor boot partition filesystem module |
| 33 | Vendor_boot_partition_name *string |
| 34 | // Name of the init boot partition filesystem module |
| 35 | Init_boot_partition_name *string |
| 36 | // Name of the system partition filesystem module |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 37 | System_partition_name *string |
Jihoon Kang | e7e3ec8 | 2025-01-02 21:29:14 +0000 | [diff] [blame] | 38 | // Name of the system_ext partition filesystem module |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 39 | System_ext_partition_name *string |
Jihoon Kang | e7e3ec8 | 2025-01-02 21:29:14 +0000 | [diff] [blame] | 40 | // Name of the product partition filesystem module |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 41 | Product_partition_name *string |
Jihoon Kang | e7e3ec8 | 2025-01-02 21:29:14 +0000 | [diff] [blame] | 42 | // Name of the vendor partition filesystem module |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 43 | Vendor_partition_name *string |
Jihoon Kang | e7e3ec8 | 2025-01-02 21:29:14 +0000 | [diff] [blame] | 44 | // Name of the odm partition filesystem module |
Spandan Das | c571716 | 2024-11-01 18:33:57 +0000 | [diff] [blame] | 45 | Odm_partition_name *string |
Jihoon Kang | e7e3ec8 | 2025-01-02 21:29:14 +0000 | [diff] [blame] | 46 | // Name of the recovery partition filesystem module |
| 47 | Recovery_partition_name *string |
Cole Faust | 3552eb6 | 2024-11-06 18:07:26 -0800 | [diff] [blame] | 48 | // The vbmeta partition and its "chained" partitions |
| 49 | Vbmeta_partitions []string |
Jihoon Kang | e7e3ec8 | 2025-01-02 21:29:14 +0000 | [diff] [blame] | 50 | // Name of the userdata partition filesystem module |
mrziwang | 23ba876 | 2024-11-07 16:21:53 -0800 | [diff] [blame] | 51 | Userdata_partition_name *string |
Spandan Das | a039400 | 2025-01-07 18:38:34 +0000 | [diff] [blame] | 52 | // Name of the system_dlkm partition filesystem module |
| 53 | System_dlkm_partition_name *string |
| 54 | // Name of the vendor_dlkm partition filesystem module |
| 55 | Vendor_dlkm_partition_name *string |
| 56 | // Name of the odm_dlkm partition filesystem module |
| 57 | Odm_dlkm_partition_name *string |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Jihoon Kang | 3be1716 | 2025-01-09 20:51:54 +0000 | [diff] [blame] | 60 | type DeviceProperties struct { |
| 61 | // Path to the prebuilt bootloader that would be copied to PRODUCT_OUT |
| 62 | Bootloader *string `android:"path"` |
| 63 | } |
| 64 | |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 65 | type androidDevice struct { |
| 66 | android.ModuleBase |
| 67 | |
| 68 | partitionProps PartitionNameProperties |
Jihoon Kang | 3be1716 | 2025-01-09 20:51:54 +0000 | [diff] [blame] | 69 | |
| 70 | deviceProps DeviceProperties |
| 71 | |
| 72 | // copyToProductOutTimestamp for copying necessary files to PRODUCT_OUT |
| 73 | copyToProductOutTimestamp android.WritablePath |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | func AndroidDeviceFactory() android.Module { |
| 77 | module := &androidDevice{} |
Jihoon Kang | 3be1716 | 2025-01-09 20:51:54 +0000 | [diff] [blame] | 78 | module.AddProperties(&module.partitionProps, &module.deviceProps) |
Cole Faust | 341d5f1 | 2025-01-07 15:32:38 -0800 | [diff] [blame] | 79 | android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 80 | return module |
| 81 | } |
| 82 | |
Cole Faust | b55a41c | 2025-01-09 16:53:58 -0800 | [diff] [blame^] | 83 | var numAutogeneratedAndroidDevicesOnceKey android.OnceKey = android.NewOnceKey("num_auto_generated_anroid_devices") |
| 84 | |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 85 | type partitionDepTagType struct { |
| 86 | blueprint.BaseDependencyTag |
| 87 | } |
| 88 | |
Cole Faust | 7724344 | 2025-01-09 15:49:15 -0800 | [diff] [blame] | 89 | type superPartitionDepTagType struct { |
| 90 | blueprint.BaseDependencyTag |
| 91 | } |
| 92 | |
| 93 | var superPartitionDepTag superPartitionDepTagType |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 94 | var filesystemDepTag partitionDepTagType |
| 95 | |
| 96 | func (a *androidDevice) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 97 | addDependencyIfDefined := func(dep *string) { |
| 98 | if dep != nil { |
Cole Faust | 341d5f1 | 2025-01-07 15:32:38 -0800 | [diff] [blame] | 99 | ctx.AddDependency(ctx.Module(), filesystemDepTag, proptools.String(dep)) |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | |
Cole Faust | 7724344 | 2025-01-09 15:49:15 -0800 | [diff] [blame] | 103 | if a.partitionProps.Super_partition_name != nil { |
| 104 | ctx.AddDependency(ctx.Module(), superPartitionDepTag, *a.partitionProps.Super_partition_name) |
| 105 | } |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 106 | addDependencyIfDefined(a.partitionProps.Boot_partition_name) |
Jihoon Kang | 9e08700 | 2025-01-08 19:12:23 +0000 | [diff] [blame] | 107 | addDependencyIfDefined(a.partitionProps.Init_boot_partition_name) |
Spandan Das | ef200ac | 2025-01-08 01:42:45 +0000 | [diff] [blame] | 108 | addDependencyIfDefined(a.partitionProps.Vendor_boot_partition_name) |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 109 | addDependencyIfDefined(a.partitionProps.System_partition_name) |
| 110 | addDependencyIfDefined(a.partitionProps.System_ext_partition_name) |
| 111 | addDependencyIfDefined(a.partitionProps.Product_partition_name) |
| 112 | addDependencyIfDefined(a.partitionProps.Vendor_partition_name) |
Spandan Das | c571716 | 2024-11-01 18:33:57 +0000 | [diff] [blame] | 113 | addDependencyIfDefined(a.partitionProps.Odm_partition_name) |
mrziwang | 23ba876 | 2024-11-07 16:21:53 -0800 | [diff] [blame] | 114 | addDependencyIfDefined(a.partitionProps.Userdata_partition_name) |
Spandan Das | a039400 | 2025-01-07 18:38:34 +0000 | [diff] [blame] | 115 | addDependencyIfDefined(a.partitionProps.System_dlkm_partition_name) |
| 116 | addDependencyIfDefined(a.partitionProps.Vendor_dlkm_partition_name) |
| 117 | addDependencyIfDefined(a.partitionProps.Odm_dlkm_partition_name) |
Spandan Das | ef200ac | 2025-01-08 01:42:45 +0000 | [diff] [blame] | 118 | addDependencyIfDefined(a.partitionProps.Recovery_partition_name) |
Cole Faust | 3552eb6 | 2024-11-06 18:07:26 -0800 | [diff] [blame] | 119 | for _, vbmetaPartition := range a.partitionProps.Vbmeta_partitions { |
| 120 | ctx.AddDependency(ctx.Module(), filesystemDepTag, vbmetaPartition) |
| 121 | } |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Jihoon Kang | 3be1716 | 2025-01-09 20:51:54 +0000 | [diff] [blame] | 124 | func (a *androidDevice) copyToProductOut(ctx android.ModuleContext, builder *android.RuleBuilder, src android.Path, dest string) { |
| 125 | destPath := android.PathForModuleInPartitionInstall(ctx, "").Join(ctx, dest) |
| 126 | builder.Command().Text("rsync").Flag("-a").Flag("--checksum").Input(src).Text(destPath.String()) |
| 127 | } |
| 128 | |
| 129 | func (a *androidDevice) copyFilesToProductOut(ctx android.ModuleContext) { |
| 130 | a.copyToProductOutTimestamp = android.PathForModuleOut(ctx, "timestamp") |
| 131 | builder := android.NewRuleBuilder(pctx, ctx) |
| 132 | builder.Command().Text("touch").Output(a.copyToProductOutTimestamp) |
| 133 | |
| 134 | // List all individual files to be copied to PRODUCT_OUT here |
| 135 | if a.deviceProps.Bootloader != nil { |
| 136 | a.copyToProductOut(ctx, builder, android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Bootloader)), "bootloader") |
| 137 | } |
| 138 | |
| 139 | builder.Build("copy_to_product_out", "Copy files to PRODUCT_OUT") |
| 140 | } |
| 141 | |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 142 | func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Cole Faust | 4408041 | 2024-12-20 14:17:07 -0800 | [diff] [blame] | 143 | a.buildTargetFilesZip(ctx) |
mrziwang | 2fd33a7 | 2025-01-08 12:22:08 -0800 | [diff] [blame] | 144 | var deps []android.Path |
Cole Faust | 7724344 | 2025-01-09 15:49:15 -0800 | [diff] [blame] | 145 | if proptools.String(a.partitionProps.Super_partition_name) != "" { |
| 146 | superImage := ctx.GetDirectDepWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag) |
| 147 | if info, ok := android.OtherModuleProvider(ctx, superImage, SuperImageProvider); ok { |
| 148 | assertUnset := func(prop *string, propName string) { |
| 149 | if prop != nil && *prop != "" { |
| 150 | ctx.PropertyErrorf(propName, "Cannot be set because it's already part of the super image") |
| 151 | } |
| 152 | } |
| 153 | for _, subPartitionType := range android.SortedKeys(info.SubImageInfo) { |
| 154 | switch subPartitionType { |
| 155 | case "system": |
| 156 | assertUnset(a.partitionProps.System_partition_name, "system_partition_name") |
| 157 | case "system_ext": |
| 158 | assertUnset(a.partitionProps.System_ext_partition_name, "system_ext_partition_name") |
| 159 | case "system_dlkm": |
| 160 | assertUnset(a.partitionProps.System_dlkm_partition_name, "system_dlkm_partition_name") |
| 161 | case "system_other": |
| 162 | // TODO |
| 163 | case "product": |
| 164 | assertUnset(a.partitionProps.Product_partition_name, "product_partition_name") |
| 165 | case "vendor": |
| 166 | assertUnset(a.partitionProps.Vendor_partition_name, "vendor_partition_name") |
| 167 | case "vendor_dlkm": |
| 168 | assertUnset(a.partitionProps.Vendor_dlkm_partition_name, "vendor_dlkm_partition_name") |
| 169 | case "odm": |
| 170 | assertUnset(a.partitionProps.Odm_partition_name, "odm_partition_name") |
| 171 | case "odm_dlkm": |
| 172 | assertUnset(a.partitionProps.Odm_dlkm_partition_name, "odm_dlkm_partition_name") |
| 173 | default: |
| 174 | ctx.ModuleErrorf("Unsupported sub-partition of super partition: %q", subPartitionType) |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | deps = append(deps, info.SuperImage) |
| 179 | } else { |
| 180 | ctx.ModuleErrorf("Expected super image dep to provide SuperImageProvider") |
| 181 | } |
| 182 | } |
mrziwang | 2fd33a7 | 2025-01-08 12:22:08 -0800 | [diff] [blame] | 183 | ctx.VisitDirectDepsWithTag(filesystemDepTag, func(m android.Module) { |
| 184 | imageOutput, ok := android.OtherModuleProvider(ctx, m, android.OutputFilesProvider) |
| 185 | if !ok { |
| 186 | ctx.ModuleErrorf("Partition module %s doesn't set OutputfilesProvider", m.Name()) |
| 187 | } |
| 188 | if len(imageOutput.DefaultOutputFiles) != 1 { |
| 189 | ctx.ModuleErrorf("Partition module %s should provide exact 1 output file", m.Name()) |
| 190 | } |
| 191 | deps = append(deps, imageOutput.DefaultOutputFiles[0]) |
| 192 | }) |
Jihoon Kang | 3be1716 | 2025-01-09 20:51:54 +0000 | [diff] [blame] | 193 | |
| 194 | a.copyFilesToProductOut(ctx) |
| 195 | |
Cole Faust | b55a41c | 2025-01-09 16:53:58 -0800 | [diff] [blame^] | 196 | allImagesStamp := android.PathForModuleOut(ctx, "all_images_stamp") |
mrziwang | 2fd33a7 | 2025-01-08 12:22:08 -0800 | [diff] [blame] | 197 | ctx.Build(pctx, android.BuildParams{ |
Jihoon Kang | 3be1716 | 2025-01-09 20:51:54 +0000 | [diff] [blame] | 198 | Rule: android.Touch, |
Cole Faust | b55a41c | 2025-01-09 16:53:58 -0800 | [diff] [blame^] | 199 | Output: allImagesStamp, |
Jihoon Kang | 3be1716 | 2025-01-09 20:51:54 +0000 | [diff] [blame] | 200 | Implicits: deps, |
| 201 | Validation: a.copyToProductOutTimestamp, |
mrziwang | 2fd33a7 | 2025-01-08 12:22:08 -0800 | [diff] [blame] | 202 | }) |
Cole Faust | b55a41c | 2025-01-09 16:53:58 -0800 | [diff] [blame^] | 203 | ctx.SetOutputFiles(android.Paths{allImagesStamp}, "") |
| 204 | ctx.CheckbuildFile(allImagesStamp) |
| 205 | |
| 206 | if ctx.OtherModuleIsAutoGenerated(ctx.Module()) { |
| 207 | numAutogeneratedAndroidDevices := ctx.Config().Once(numAutogeneratedAndroidDevicesOnceKey, func() interface{} { |
| 208 | return &atomic.Int32{} |
| 209 | }).(*atomic.Int32) |
| 210 | total := numAutogeneratedAndroidDevices.Add(1) |
| 211 | if total > 1 { |
| 212 | // There should only be 1 autogenerated android_device module. That one will be |
| 213 | // made the default thing to build in soong-only builds. |
| 214 | ctx.ModuleErrorf("There cannot be more than 1 autogenerated android_device module") |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | if !ctx.Config().KatiEnabled() && ctx.OtherModuleIsAutoGenerated(ctx.Module()) { |
| 219 | // In soong-only builds, build this module by default. |
| 220 | // This is the analogue to this make code: |
| 221 | // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/main.mk;l=1396;drc=6595459cdd8164a6008335f6372c9f97b9094060 |
| 222 | ctx.Phony("droidcore-unbundled", allImagesStamp) |
| 223 | } |
Cole Faust | 4408041 | 2024-12-20 14:17:07 -0800 | [diff] [blame] | 224 | } |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 225 | |
Spandan Das | ef200ac | 2025-01-08 01:42:45 +0000 | [diff] [blame] | 226 | type targetFilesZipCopy struct { |
| 227 | srcModule *string |
| 228 | destSubdir string |
| 229 | } |
| 230 | |
Cole Faust | 4408041 | 2024-12-20 14:17:07 -0800 | [diff] [blame] | 231 | func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) { |
| 232 | targetFilesDir := android.PathForModuleOut(ctx, "target_files_dir") |
| 233 | targetFilesZip := android.PathForModuleOut(ctx, "target_files.zip") |
| 234 | |
| 235 | builder := android.NewRuleBuilder(pctx, ctx) |
| 236 | builder.Command().Textf("rm -rf %s", targetFilesDir.String()) |
| 237 | builder.Command().Textf("mkdir -p %s", targetFilesDir.String()) |
Spandan Das | ef200ac | 2025-01-08 01:42:45 +0000 | [diff] [blame] | 238 | toCopy := []targetFilesZipCopy{ |
| 239 | targetFilesZipCopy{a.partitionProps.System_partition_name, "SYSTEM"}, |
| 240 | targetFilesZipCopy{a.partitionProps.System_ext_partition_name, "SYSTEM_EXT"}, |
| 241 | targetFilesZipCopy{a.partitionProps.Product_partition_name, "PRODUCT"}, |
| 242 | targetFilesZipCopy{a.partitionProps.Vendor_partition_name, "VENDOR"}, |
| 243 | targetFilesZipCopy{a.partitionProps.Odm_partition_name, "ODM"}, |
| 244 | targetFilesZipCopy{a.partitionProps.System_dlkm_partition_name, "SYSTEM_DLKM"}, |
| 245 | targetFilesZipCopy{a.partitionProps.Vendor_dlkm_partition_name, "VENDOR_DLKM"}, |
| 246 | targetFilesZipCopy{a.partitionProps.Odm_dlkm_partition_name, "ODM_DLKM"}, |
| 247 | targetFilesZipCopy{a.partitionProps.Init_boot_partition_name, "BOOT/RAMDISK"}, |
| 248 | targetFilesZipCopy{a.partitionProps.Init_boot_partition_name, "INIT_BOOT/RAMDISK"}, |
| 249 | targetFilesZipCopy{a.partitionProps.Vendor_boot_partition_name, "VENDOR_BOOT/RAMDISK"}, |
Spandan Das | 25649f5 | 2025-01-07 18:09:22 +0000 | [diff] [blame] | 250 | } |
Spandan Das | ef200ac | 2025-01-08 01:42:45 +0000 | [diff] [blame] | 251 | // TODO: Handle cases where recovery files are copied to BOOT/ or RECOVERY/ |
| 252 | // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=6211-6219?q=core%2FMakefile&ss=android%2Fplatform%2Fsuperproject%2Fmain |
| 253 | if ctx.DeviceConfig().BoardMoveRecoveryResourcesToVendorBoot() { |
| 254 | toCopy = append(toCopy, targetFilesZipCopy{a.partitionProps.Recovery_partition_name, "VENDOR_BOOT/RAMDISK"}) |
| 255 | } |
| 256 | |
| 257 | for _, zipCopy := range toCopy { |
| 258 | if zipCopy.srcModule == nil { |
Spandan Das | 25649f5 | 2025-01-07 18:09:22 +0000 | [diff] [blame] | 259 | continue |
| 260 | } |
Spandan Das | ef200ac | 2025-01-08 01:42:45 +0000 | [diff] [blame] | 261 | fsInfo := a.getFilesystemInfo(ctx, *zipCopy.srcModule) |
| 262 | subdir := zipCopy.destSubdir |
| 263 | rootDirString := fsInfo.RootDir.String() |
| 264 | if subdir == "SYSTEM" { |
| 265 | rootDirString = rootDirString + "/system" |
| 266 | } |
Spandan Das | 25649f5 | 2025-01-07 18:09:22 +0000 | [diff] [blame] | 267 | builder.Command().Textf("mkdir -p %s/%s", targetFilesDir.String(), subdir) |
Cole Faust | 4408041 | 2024-12-20 14:17:07 -0800 | [diff] [blame] | 268 | builder.Command(). |
| 269 | BuiltTool("acp"). |
Spandan Das | ef200ac | 2025-01-08 01:42:45 +0000 | [diff] [blame] | 270 | Textf("-rd %s/. %s/%s", rootDirString, targetFilesDir, subdir). |
Cole Faust | 4408041 | 2024-12-20 14:17:07 -0800 | [diff] [blame] | 271 | Implicit(fsInfo.Output) // so that the staging dir is built |
Spandan Das | ef200ac | 2025-01-08 01:42:45 +0000 | [diff] [blame] | 272 | |
Cole Faust | 4408041 | 2024-12-20 14:17:07 -0800 | [diff] [blame] | 273 | } |
Spandan Das | 9b17df2 | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 274 | // Copy cmdline, kernel etc. files of boot images |
Spandan Das | 258c08f | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 275 | if a.partitionProps.Vendor_boot_partition_name != nil { |
| 276 | bootImg := ctx.GetDirectDepWithTag(proptools.String(a.partitionProps.Vendor_boot_partition_name), filesystemDepTag) |
| 277 | bootImgInfo, _ := android.OtherModuleProvider(ctx, bootImg, BootimgInfoProvider) |
Spandan Das | 9b17df2 | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 278 | builder.Command().Textf("echo %s > %s/VENDOR_BOOT/cmdline", proptools.ShellEscape(strings.Join(bootImgInfo.Cmdline, " ")), targetFilesDir) |
| 279 | builder.Command().Textf("echo %s > %s/VENDOR_BOOT/vendor_cmdline", proptools.ShellEscape(strings.Join(bootImgInfo.Cmdline, " ")), targetFilesDir) |
| 280 | if bootImgInfo.Dtb != nil { |
| 281 | builder.Command().Textf("cp %s %s/VENDOR_BOOT/dtb", bootImgInfo.Dtb, targetFilesDir) |
| 282 | } |
Spandan Das | 2351137 | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 283 | if bootImgInfo.Bootconfig != nil { |
| 284 | builder.Command().Textf("cp %s %s/VENDOR_BOOT/vendor_bootconfig", bootImgInfo.Bootconfig, targetFilesDir) |
| 285 | } |
Spandan Das | 258c08f | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 286 | } |
| 287 | if a.partitionProps.Boot_partition_name != nil { |
| 288 | bootImg := ctx.GetDirectDepWithTag(proptools.String(a.partitionProps.Boot_partition_name), filesystemDepTag) |
| 289 | bootImgInfo, _ := android.OtherModuleProvider(ctx, bootImg, BootimgInfoProvider) |
Spandan Das | 9b17df2 | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 290 | builder.Command().Textf("echo %s > %s/BOOT/cmdline", proptools.ShellEscape(strings.Join(bootImgInfo.Cmdline, " ")), targetFilesDir) |
| 291 | if bootImgInfo.Dtb != nil { |
| 292 | builder.Command().Textf("cp %s %s/BOOT/dtb", bootImgInfo.Dtb, targetFilesDir) |
| 293 | } |
| 294 | if bootImgInfo.Kernel != nil { |
| 295 | builder.Command().Textf("cp %s %s/BOOT/kernel", bootImgInfo.Kernel, targetFilesDir) |
| 296 | // Even though kernel is not used to build vendor_boot, copy the kernel to VENDOR_BOOT to match the behavior of make packaging. |
| 297 | builder.Command().Textf("cp %s %s/VENDOR_BOOT/kernel", bootImgInfo.Kernel, targetFilesDir) |
| 298 | } |
Spandan Das | 2351137 | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 299 | if bootImgInfo.Bootconfig != nil { |
| 300 | builder.Command().Textf("cp %s %s/BOOT/bootconfig", bootImgInfo.Bootconfig, targetFilesDir) |
| 301 | } |
Spandan Das | 258c08f | 2025-01-08 23:30:45 +0000 | [diff] [blame] | 302 | } |
| 303 | |
Cole Faust | 4408041 | 2024-12-20 14:17:07 -0800 | [diff] [blame] | 304 | builder.Command(). |
| 305 | BuiltTool("soong_zip"). |
| 306 | Text("-d"). |
| 307 | FlagWithOutput("-o ", targetFilesZip). |
| 308 | FlagWithArg("-C ", targetFilesDir.String()). |
| 309 | FlagWithArg("-D ", targetFilesDir.String()). |
| 310 | Text("-sha256") |
| 311 | builder.Build("target_files_"+ctx.ModuleName(), "Build target_files.zip") |
| 312 | } |
| 313 | |
| 314 | func (a *androidDevice) getFilesystemInfo(ctx android.ModuleContext, depName string) FilesystemInfo { |
| 315 | fsMod := ctx.GetDirectDepWithTag(depName, filesystemDepTag) |
| 316 | fsInfo, ok := android.OtherModuleProvider(ctx, fsMod, FilesystemProvider) |
| 317 | if !ok { |
| 318 | ctx.ModuleErrorf("Expected dependency %s to be a filesystem", depName) |
| 319 | } |
| 320 | return fsInfo |
Jihoon Kang | f2c5398 | 2024-10-09 17:32:52 +0000 | [diff] [blame] | 321 | } |