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