Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 1 | // Copyright 2020 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 | package cc |
| 15 | |
| 16 | // This file defines snapshot prebuilt modules, e.g. vendor snapshot and recovery snapshot. Such |
| 17 | // snapshot modules will override original source modules with setting BOARD_VNDK_VERSION, with |
| 18 | // snapshot mutators and snapshot information maps which are also defined in this file. |
| 19 | |
| 20 | import ( |
Justin DeMartino | 383bfb3 | 2021-02-24 10:49:43 -0800 | [diff] [blame] | 21 | "path/filepath" |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 22 | "strings" |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 23 | |
| 24 | "android/soong/android" |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 25 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 26 | "github.com/google/blueprint" |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 27 | ) |
| 28 | |
| 29 | // Defines the specifics of different images to which the snapshot process is applicable, e.g., |
| 30 | // vendor, recovery, ramdisk. |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 31 | type SnapshotImage interface { |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 32 | // Returns true if a snapshot should be generated for this image. |
| 33 | shouldGenerateSnapshot(ctx android.SingletonContext) bool |
| 34 | |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 35 | // Function that returns true if the module is included in this image. |
| 36 | // Using a function return instead of a value to prevent early |
| 37 | // evalution of a function that may be not be defined. |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 38 | inImage(m LinkableInterface) func() bool |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 39 | |
Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 40 | // Returns true if the module is private and must not be included in the |
| 41 | // snapshot. For example VNDK-private modules must return true for the |
| 42 | // vendor snapshots. But false for the recovery snapshots. |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 43 | private(m LinkableInterface) bool |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 44 | |
| 45 | // Returns true if a dir under source tree is an SoC-owned proprietary |
| 46 | // directory, such as device/, vendor/, etc. |
| 47 | // |
| 48 | // For a given snapshot (e.g., vendor, recovery, etc.) if |
Justin DeMartino | 383bfb3 | 2021-02-24 10:49:43 -0800 | [diff] [blame] | 49 | // isProprietaryPath(dir, deviceConfig) returns true, then the module in dir |
| 50 | // will be built from sources. |
| 51 | isProprietaryPath(dir string, deviceConfig android.DeviceConfig) bool |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 52 | |
| 53 | // Whether to include VNDK in the snapshot for this image. |
| 54 | includeVndk() bool |
| 55 | |
| 56 | // Whether a given module has been explicitly excluded from the |
| 57 | // snapshot, e.g., using the exclude_from_vendor_snapshot or |
| 58 | // exclude_from_recovery_snapshot properties. |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 59 | excludeFromSnapshot(m LinkableInterface) bool |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 60 | |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 61 | // Returns true if the build is using a snapshot for this image. |
| 62 | isUsingSnapshot(cfg android.DeviceConfig) bool |
| 63 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 64 | // Returns a version of which the snapshot should be used in this target. |
| 65 | // This will only be meaningful when isUsingSnapshot is true. |
| 66 | targetSnapshotVersion(cfg android.DeviceConfig) string |
Inseob Kim | 7cf1465 | 2021-01-06 23:06:52 +0900 | [diff] [blame] | 67 | |
| 68 | // Whether to exclude a given module from the directed snapshot or not. |
| 69 | // If the makefile variable DIRECTED_{IMAGE}_SNAPSHOT is true, directed snapshot is turned on, |
| 70 | // and only modules listed in {IMAGE}_SNAPSHOT_MODULES will be captured. |
| 71 | excludeFromDirectedSnapshot(cfg android.DeviceConfig, name string) bool |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 72 | |
| 73 | // The image variant name for this snapshot image. |
| 74 | // For example, recovery snapshot image will return "recovery", and vendor snapshot image will |
| 75 | // return "vendor." + version. |
| 76 | imageVariantName(cfg android.DeviceConfig) string |
| 77 | |
| 78 | // The variant suffix for snapshot modules. For example, vendor snapshot modules will have |
| 79 | // ".vendor" as their suffix. |
| 80 | moduleNameSuffix() string |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | type vendorSnapshotImage struct{} |
| 84 | type recoverySnapshotImage struct{} |
| 85 | |
Justin DeMartino | 383bfb3 | 2021-02-24 10:49:43 -0800 | [diff] [blame] | 86 | type directoryMap map[string]bool |
| 87 | |
| 88 | var ( |
| 89 | // Modules under following directories are ignored. They are OEM's and vendor's |
| 90 | // proprietary modules(device/, kernel/, vendor/, and hardware/). |
| 91 | defaultDirectoryExcludedMap = directoryMap{ |
| 92 | "device": true, |
| 93 | "hardware": true, |
| 94 | "kernel": true, |
| 95 | "vendor": true, |
| 96 | } |
| 97 | |
| 98 | // Modules under following directories are included as they are in AOSP, |
| 99 | // although hardware/ and kernel/ are normally for vendor's own. |
| 100 | defaultDirectoryIncludedMap = directoryMap{ |
| 101 | "kernel/configs": true, |
| 102 | "kernel/prebuilts": true, |
| 103 | "kernel/tests": true, |
| 104 | "hardware/interfaces": true, |
| 105 | "hardware/libhardware": true, |
| 106 | "hardware/libhardware_legacy": true, |
| 107 | "hardware/ril": true, |
| 108 | } |
| 109 | ) |
| 110 | |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 111 | func (vendorSnapshotImage) Init(ctx android.RegistrationContext) { |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 112 | ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton) |
| 113 | ctx.RegisterModuleType("vendor_snapshot", vendorSnapshotFactory) |
| 114 | ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory) |
| 115 | ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory) |
| 116 | ctx.RegisterModuleType("vendor_snapshot_header", VendorSnapshotHeaderFactory) |
| 117 | ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory) |
| 118 | ctx.RegisterModuleType("vendor_snapshot_object", VendorSnapshotObjectFactory) |
Inseob Kim | e9aec6a | 2021-01-05 20:03:22 +0900 | [diff] [blame] | 119 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 120 | ctx.RegisterSingletonType("vendor-fake-snapshot", VendorFakeSnapshotSingleton) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 121 | } |
| 122 | |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 123 | func (vendorSnapshotImage) RegisterAdditionalModule(ctx android.RegistrationContext, name string, factory android.ModuleFactory) { |
| 124 | ctx.RegisterModuleType(name, factory) |
| 125 | } |
| 126 | |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 127 | func (vendorSnapshotImage) shouldGenerateSnapshot(ctx android.SingletonContext) bool { |
| 128 | // BOARD_VNDK_VERSION must be set to 'current' in order to generate a snapshot. |
| 129 | return ctx.DeviceConfig().VndkVersion() == "current" |
| 130 | } |
| 131 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 132 | func (vendorSnapshotImage) inImage(m LinkableInterface) func() bool { |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 133 | return m.InVendor |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 134 | } |
| 135 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 136 | func (vendorSnapshotImage) private(m LinkableInterface) bool { |
Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 137 | return m.IsVndkPrivate() |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 138 | } |
| 139 | |
Justin DeMartino | 383bfb3 | 2021-02-24 10:49:43 -0800 | [diff] [blame] | 140 | func isDirectoryExcluded(dir string, excludedMap directoryMap, includedMap directoryMap) bool { |
| 141 | if dir == "." || dir == "/" { |
| 142 | return false |
| 143 | } |
| 144 | if includedMap[dir] { |
| 145 | return false |
| 146 | } else if excludedMap[dir] { |
| 147 | return true |
| 148 | } else if defaultDirectoryIncludedMap[dir] { |
| 149 | return false |
| 150 | } else if defaultDirectoryExcludedMap[dir] { |
| 151 | return true |
| 152 | } else { |
| 153 | return isDirectoryExcluded(filepath.Dir(dir), excludedMap, includedMap) |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | func (vendorSnapshotImage) isProprietaryPath(dir string, deviceConfig android.DeviceConfig) bool { |
| 158 | return isDirectoryExcluded(dir, deviceConfig.VendorSnapshotDirsExcludedMap(), deviceConfig.VendorSnapshotDirsIncludedMap()) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | // vendor snapshot includes static/header libraries with vndk: {enabled: true}. |
| 162 | func (vendorSnapshotImage) includeVndk() bool { |
| 163 | return true |
| 164 | } |
| 165 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 166 | func (vendorSnapshotImage) excludeFromSnapshot(m LinkableInterface) bool { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 167 | return m.ExcludeFromVendorSnapshot() |
| 168 | } |
| 169 | |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 170 | func (vendorSnapshotImage) isUsingSnapshot(cfg android.DeviceConfig) bool { |
| 171 | vndkVersion := cfg.VndkVersion() |
| 172 | return vndkVersion != "current" && vndkVersion != "" |
| 173 | } |
| 174 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 175 | func (vendorSnapshotImage) targetSnapshotVersion(cfg android.DeviceConfig) string { |
| 176 | return cfg.VndkVersion() |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 177 | } |
| 178 | |
Inseob Kim | 7cf1465 | 2021-01-06 23:06:52 +0900 | [diff] [blame] | 179 | // returns true iff a given module SHOULD BE EXCLUDED, false if included |
| 180 | func (vendorSnapshotImage) excludeFromDirectedSnapshot(cfg android.DeviceConfig, name string) bool { |
| 181 | // If we're using full snapshot, not directed snapshot, capture every module |
| 182 | if !cfg.DirectedVendorSnapshot() { |
| 183 | return false |
| 184 | } |
| 185 | // Else, checks if name is in VENDOR_SNAPSHOT_MODULES. |
| 186 | return !cfg.VendorSnapshotModules()[name] |
| 187 | } |
| 188 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 189 | func (vendorSnapshotImage) imageVariantName(cfg android.DeviceConfig) string { |
| 190 | return VendorVariationPrefix + cfg.VndkVersion() |
| 191 | } |
| 192 | |
| 193 | func (vendorSnapshotImage) moduleNameSuffix() string { |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 194 | return VendorSuffix |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | func (recoverySnapshotImage) init(ctx android.RegistrationContext) { |
| 198 | ctx.RegisterSingletonType("recovery-snapshot", RecoverySnapshotSingleton) |
| 199 | ctx.RegisterModuleType("recovery_snapshot", recoverySnapshotFactory) |
| 200 | ctx.RegisterModuleType("recovery_snapshot_shared", RecoverySnapshotSharedFactory) |
| 201 | ctx.RegisterModuleType("recovery_snapshot_static", RecoverySnapshotStaticFactory) |
| 202 | ctx.RegisterModuleType("recovery_snapshot_header", RecoverySnapshotHeaderFactory) |
| 203 | ctx.RegisterModuleType("recovery_snapshot_binary", RecoverySnapshotBinaryFactory) |
| 204 | ctx.RegisterModuleType("recovery_snapshot_object", RecoverySnapshotObjectFactory) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 205 | } |
| 206 | |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 207 | func (recoverySnapshotImage) shouldGenerateSnapshot(ctx android.SingletonContext) bool { |
| 208 | // RECOVERY_SNAPSHOT_VERSION must be set to 'current' in order to generate a |
| 209 | // snapshot. |
| 210 | return ctx.DeviceConfig().RecoverySnapshotVersion() == "current" |
| 211 | } |
| 212 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 213 | func (recoverySnapshotImage) inImage(m LinkableInterface) func() bool { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 214 | return m.InRecovery |
| 215 | } |
| 216 | |
Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 217 | // recovery snapshot does not have private libraries. |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 218 | func (recoverySnapshotImage) private(m LinkableInterface) bool { |
Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 219 | return false |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 220 | } |
| 221 | |
Justin DeMartino | 383bfb3 | 2021-02-24 10:49:43 -0800 | [diff] [blame] | 222 | func (recoverySnapshotImage) isProprietaryPath(dir string, deviceConfig android.DeviceConfig) bool { |
| 223 | return isDirectoryExcluded(dir, deviceConfig.RecoverySnapshotDirsExcludedMap(), deviceConfig.RecoverySnapshotDirsIncludedMap()) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | // recovery snapshot does NOT treat vndk specially. |
| 227 | func (recoverySnapshotImage) includeVndk() bool { |
| 228 | return false |
| 229 | } |
| 230 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 231 | func (recoverySnapshotImage) excludeFromSnapshot(m LinkableInterface) bool { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 232 | return m.ExcludeFromRecoverySnapshot() |
| 233 | } |
| 234 | |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 235 | func (recoverySnapshotImage) isUsingSnapshot(cfg android.DeviceConfig) bool { |
| 236 | recoverySnapshotVersion := cfg.RecoverySnapshotVersion() |
| 237 | return recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" |
| 238 | } |
| 239 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 240 | func (recoverySnapshotImage) targetSnapshotVersion(cfg android.DeviceConfig) string { |
| 241 | return cfg.RecoverySnapshotVersion() |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 242 | } |
| 243 | |
Inseob Kim | 7cf1465 | 2021-01-06 23:06:52 +0900 | [diff] [blame] | 244 | func (recoverySnapshotImage) excludeFromDirectedSnapshot(cfg android.DeviceConfig, name string) bool { |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 245 | // If we're using full snapshot, not directed snapshot, capture every module |
| 246 | if !cfg.DirectedRecoverySnapshot() { |
| 247 | return false |
| 248 | } |
| 249 | // Else, checks if name is in RECOVERY_SNAPSHOT_MODULES. |
| 250 | return !cfg.RecoverySnapshotModules()[name] |
Inseob Kim | 7cf1465 | 2021-01-06 23:06:52 +0900 | [diff] [blame] | 251 | } |
| 252 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 253 | func (recoverySnapshotImage) imageVariantName(cfg android.DeviceConfig) string { |
| 254 | return android.RecoveryVariation |
| 255 | } |
| 256 | |
| 257 | func (recoverySnapshotImage) moduleNameSuffix() string { |
| 258 | return recoverySuffix |
| 259 | } |
| 260 | |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 261 | var VendorSnapshotImageSingleton vendorSnapshotImage |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 262 | var recoverySnapshotImageSingleton recoverySnapshotImage |
| 263 | |
| 264 | func init() { |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 265 | VendorSnapshotImageSingleton.Init(android.InitRegistrationContext) |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 266 | recoverySnapshotImageSingleton.init(android.InitRegistrationContext) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | const ( |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 270 | snapshotHeaderSuffix = "_header." |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 271 | SnapshotSharedSuffix = "_shared." |
| 272 | SnapshotStaticSuffix = "_static." |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 273 | snapshotBinarySuffix = "_binary." |
| 274 | snapshotObjectSuffix = "_object." |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 275 | SnapshotRlibSuffix = "_rlib." |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 276 | ) |
| 277 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 278 | type SnapshotProperties struct { |
| 279 | Header_libs []string `android:"arch_variant"` |
| 280 | Static_libs []string `android:"arch_variant"` |
| 281 | Shared_libs []string `android:"arch_variant"` |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 282 | Rlibs []string `android:"arch_variant"` |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 283 | Vndk_libs []string `android:"arch_variant"` |
| 284 | Binaries []string `android:"arch_variant"` |
| 285 | Objects []string `android:"arch_variant"` |
| 286 | } |
| 287 | |
| 288 | type snapshot struct { |
| 289 | android.ModuleBase |
| 290 | |
| 291 | properties SnapshotProperties |
| 292 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 293 | baseSnapshot BaseSnapshotDecorator |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 294 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 295 | image SnapshotImage |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | func (s *snapshot) ImageMutatorBegin(ctx android.BaseModuleContext) { |
| 299 | cfg := ctx.DeviceConfig() |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 300 | if !s.image.isUsingSnapshot(cfg) || s.image.targetSnapshotVersion(cfg) != s.baseSnapshot.Version() { |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 301 | s.Disable() |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | func (s *snapshot) CoreVariantNeeded(ctx android.BaseModuleContext) bool { |
| 306 | return false |
| 307 | } |
| 308 | |
| 309 | func (s *snapshot) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 310 | return false |
| 311 | } |
| 312 | |
| 313 | func (s *snapshot) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 314 | return false |
| 315 | } |
| 316 | |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 317 | func (s *snapshot) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 318 | return false |
| 319 | } |
| 320 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 321 | func (s *snapshot) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { |
| 322 | return false |
| 323 | } |
| 324 | |
| 325 | func (s *snapshot) ExtraImageVariations(ctx android.BaseModuleContext) []string { |
| 326 | return []string{s.image.imageVariantName(ctx.DeviceConfig())} |
| 327 | } |
| 328 | |
| 329 | func (s *snapshot) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) { |
| 330 | } |
| 331 | |
| 332 | func (s *snapshot) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 333 | // Nothing, the snapshot module is only used to forward dependency information in DepsMutator. |
| 334 | } |
| 335 | |
Justin Yun | 07b9f86 | 2021-02-26 14:00:03 +0900 | [diff] [blame] | 336 | func getSnapshotNameSuffix(moduleSuffix, version, arch string) string { |
| 337 | versionSuffix := version |
| 338 | if arch != "" { |
| 339 | versionSuffix += "." + arch |
| 340 | } |
| 341 | return moduleSuffix + versionSuffix |
| 342 | } |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 343 | |
Justin Yun | 07b9f86 | 2021-02-26 14:00:03 +0900 | [diff] [blame] | 344 | func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 345 | collectSnapshotMap := func(names []string, snapshotSuffix, moduleSuffix string) map[string]string { |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 346 | snapshotMap := make(map[string]string) |
Justin Yun | 4813867 | 2021-02-25 18:21:27 +0900 | [diff] [blame] | 347 | for _, name := range names { |
| 348 | snapshotMap[name] = name + |
Justin Yun | 07b9f86 | 2021-02-26 14:00:03 +0900 | [diff] [blame] | 349 | getSnapshotNameSuffix(snapshotSuffix+moduleSuffix, |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 350 | s.baseSnapshot.Version(), |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 351 | ctx.DeviceConfig().Arches()[0].ArchType.String()) |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 352 | } |
| 353 | return snapshotMap |
| 354 | } |
| 355 | |
| 356 | snapshotSuffix := s.image.moduleNameSuffix() |
Justin Yun | 07b9f86 | 2021-02-26 14:00:03 +0900 | [diff] [blame] | 357 | headers := collectSnapshotMap(s.properties.Header_libs, snapshotSuffix, snapshotHeaderSuffix) |
| 358 | binaries := collectSnapshotMap(s.properties.Binaries, snapshotSuffix, snapshotBinarySuffix) |
| 359 | objects := collectSnapshotMap(s.properties.Objects, snapshotSuffix, snapshotObjectSuffix) |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 360 | staticLibs := collectSnapshotMap(s.properties.Static_libs, snapshotSuffix, SnapshotStaticSuffix) |
| 361 | sharedLibs := collectSnapshotMap(s.properties.Shared_libs, snapshotSuffix, SnapshotSharedSuffix) |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 362 | rlibs := collectSnapshotMap(s.properties.Rlibs, snapshotSuffix, SnapshotRlibSuffix) |
Justin Yun | 07b9f86 | 2021-02-26 14:00:03 +0900 | [diff] [blame] | 363 | vndkLibs := collectSnapshotMap(s.properties.Vndk_libs, "", vndkSuffix) |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 364 | for k, v := range vndkLibs { |
| 365 | sharedLibs[k] = v |
| 366 | } |
Justin Yun | 07b9f86 | 2021-02-26 14:00:03 +0900 | [diff] [blame] | 367 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 368 | ctx.SetProvider(SnapshotInfoProvider, SnapshotInfo{ |
| 369 | HeaderLibs: headers, |
| 370 | Binaries: binaries, |
| 371 | Objects: objects, |
| 372 | StaticLibs: staticLibs, |
| 373 | SharedLibs: sharedLibs, |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 374 | Rlibs: rlibs, |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 375 | }) |
| 376 | } |
| 377 | |
| 378 | type SnapshotInfo struct { |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 379 | HeaderLibs, Binaries, Objects, StaticLibs, SharedLibs, Rlibs map[string]string |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | var SnapshotInfoProvider = blueprint.NewMutatorProvider(SnapshotInfo{}, "deps") |
| 383 | |
| 384 | var _ android.ImageInterface = (*snapshot)(nil) |
| 385 | |
| 386 | func vendorSnapshotFactory() android.Module { |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 387 | return snapshotFactory(VendorSnapshotImageSingleton) |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | func recoverySnapshotFactory() android.Module { |
| 391 | return snapshotFactory(recoverySnapshotImageSingleton) |
| 392 | } |
| 393 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 394 | func snapshotFactory(image SnapshotImage) android.Module { |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 395 | snapshot := &snapshot{} |
| 396 | snapshot.image = image |
| 397 | snapshot.AddProperties( |
| 398 | &snapshot.properties, |
| 399 | &snapshot.baseSnapshot.baseProperties) |
| 400 | android.InitAndroidArchModule(snapshot, android.DeviceSupported, android.MultilibBoth) |
| 401 | return snapshot |
| 402 | } |
| 403 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 404 | type BaseSnapshotDecoratorProperties struct { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 405 | // snapshot version. |
| 406 | Version string |
| 407 | |
| 408 | // Target arch name of the snapshot (e.g. 'arm64' for variant 'aosp_arm64') |
| 409 | Target_arch string |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 410 | |
Colin Cross | a889080 | 2021-01-22 14:06:33 -0800 | [diff] [blame] | 411 | // Suffix to be added to the module name when exporting to Android.mk, e.g. ".vendor". |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 412 | Androidmk_suffix string `blueprint:"mutated"` |
Colin Cross | a889080 | 2021-01-22 14:06:33 -0800 | [diff] [blame] | 413 | |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 414 | // Suffix to be added to the module name, e.g., vendor_shared, |
| 415 | // recovery_shared, etc. |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 416 | ModuleSuffix string `blueprint:"mutated"` |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 417 | } |
| 418 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 419 | // BaseSnapshotDecorator provides common basic functions for all snapshot modules, such as snapshot |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 420 | // version, snapshot arch, etc. It also adds a special suffix to Soong module name, so it doesn't |
| 421 | // collide with source modules. e.g. the following example module, |
| 422 | // |
| 423 | // vendor_snapshot_static { |
| 424 | // name: "libbase", |
| 425 | // arch: "arm64", |
| 426 | // version: 30, |
| 427 | // ... |
| 428 | // } |
| 429 | // |
| 430 | // will be seen as "libbase.vendor_static.30.arm64" by Soong. |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 431 | type BaseSnapshotDecorator struct { |
| 432 | baseProperties BaseSnapshotDecoratorProperties |
| 433 | image SnapshotImage |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 434 | } |
| 435 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 436 | func (p *BaseSnapshotDecorator) Name(name string) string { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 437 | return name + p.NameSuffix() |
| 438 | } |
| 439 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 440 | func (p *BaseSnapshotDecorator) NameSuffix() string { |
| 441 | return getSnapshotNameSuffix(p.moduleSuffix(), p.Version(), p.Arch()) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 442 | } |
| 443 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 444 | func (p *BaseSnapshotDecorator) Version() string { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 445 | return p.baseProperties.Version |
| 446 | } |
| 447 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 448 | func (p *BaseSnapshotDecorator) Arch() string { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 449 | return p.baseProperties.Target_arch |
| 450 | } |
| 451 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 452 | func (p *BaseSnapshotDecorator) moduleSuffix() string { |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 453 | return p.baseProperties.ModuleSuffix |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 454 | } |
| 455 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 456 | func (p *BaseSnapshotDecorator) IsSnapshotPrebuilt() bool { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 457 | return true |
| 458 | } |
| 459 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 460 | func (p *BaseSnapshotDecorator) SnapshotAndroidMkSuffix() string { |
Colin Cross | a889080 | 2021-01-22 14:06:33 -0800 | [diff] [blame] | 461 | return p.baseProperties.Androidmk_suffix |
| 462 | } |
| 463 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 464 | func (p *BaseSnapshotDecorator) SetSnapshotAndroidMkSuffix(ctx android.ModuleContext, variant string) { |
Jose Galmes | 7fdc336 | 2021-05-26 21:16:52 -0700 | [diff] [blame] | 465 | // If there are any 2 or more variations among {core, product, vendor, recovery} |
| 466 | // we have to add the androidmk suffix to avoid duplicate modules with the same |
| 467 | // name. |
| 468 | variations := append(ctx.Target().Variations(), blueprint.Variation{ |
Bill Peckham | 4016d7b | 2021-05-20 11:54:21 -0700 | [diff] [blame] | 469 | Mutator: "image", |
| 470 | Variation: android.CoreVariation}) |
| 471 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 472 | if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(LinkableInterface).BaseModuleName()) { |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 473 | p.baseProperties.Androidmk_suffix = p.image.moduleNameSuffix() |
Bill Peckham | 4016d7b | 2021-05-20 11:54:21 -0700 | [diff] [blame] | 474 | return |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 475 | } |
Bill Peckham | 4016d7b | 2021-05-20 11:54:21 -0700 | [diff] [blame] | 476 | |
Jose Galmes | 7fdc336 | 2021-05-26 21:16:52 -0700 | [diff] [blame] | 477 | variations = append(ctx.Target().Variations(), blueprint.Variation{ |
Bill Peckham | 4016d7b | 2021-05-20 11:54:21 -0700 | [diff] [blame] | 478 | Mutator: "image", |
| 479 | Variation: ProductVariationPrefix + ctx.DeviceConfig().PlatformVndkVersion()}) |
| 480 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 481 | if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(LinkableInterface).BaseModuleName()) { |
Bill Peckham | 4016d7b | 2021-05-20 11:54:21 -0700 | [diff] [blame] | 482 | p.baseProperties.Androidmk_suffix = p.image.moduleNameSuffix() |
| 483 | return |
| 484 | } |
| 485 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 486 | images := []SnapshotImage{VendorSnapshotImageSingleton, recoverySnapshotImageSingleton} |
Jose Galmes | 7fdc336 | 2021-05-26 21:16:52 -0700 | [diff] [blame] | 487 | |
| 488 | for _, image := range images { |
| 489 | if p.image == image { |
| 490 | continue |
| 491 | } |
| 492 | variations = append(ctx.Target().Variations(), blueprint.Variation{ |
| 493 | Mutator: "image", |
| 494 | Variation: image.imageVariantName(ctx.DeviceConfig())}) |
| 495 | |
| 496 | if ctx.OtherModuleFarDependencyVariantExists(variations, |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 497 | ctx.Module().(LinkableInterface).BaseModuleName()+ |
Jose Galmes | 7fdc336 | 2021-05-26 21:16:52 -0700 | [diff] [blame] | 498 | getSnapshotNameSuffix( |
| 499 | image.moduleNameSuffix()+variant, |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 500 | p.Version(), |
Jose Galmes | 7fdc336 | 2021-05-26 21:16:52 -0700 | [diff] [blame] | 501 | ctx.DeviceConfig().Arches()[0].ArchType.String())) { |
| 502 | p.baseProperties.Androidmk_suffix = p.image.moduleNameSuffix() |
| 503 | return |
| 504 | } |
| 505 | } |
| 506 | |
Bill Peckham | 4016d7b | 2021-05-20 11:54:21 -0700 | [diff] [blame] | 507 | p.baseProperties.Androidmk_suffix = "" |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 508 | } |
| 509 | |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 510 | // Call this with a module suffix after creating a snapshot module, such as |
| 511 | // vendorSnapshotSharedSuffix, recoverySnapshotBinarySuffix, etc. |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 512 | func (p *BaseSnapshotDecorator) Init(m LinkableInterface, image SnapshotImage, moduleSuffix string) { |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 513 | p.image = image |
| 514 | p.baseProperties.ModuleSuffix = image.moduleNameSuffix() + moduleSuffix |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 515 | m.AddProperties(&p.baseProperties) |
| 516 | android.AddLoadHook(m, func(ctx android.LoadHookContext) { |
| 517 | vendorSnapshotLoadHook(ctx, p) |
| 518 | }) |
| 519 | } |
| 520 | |
| 521 | // vendorSnapshotLoadHook disables snapshots if it's not BOARD_VNDK_VERSION. |
| 522 | // As vendor snapshot is only for vendor, such modules won't be used at all. |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 523 | func vendorSnapshotLoadHook(ctx android.LoadHookContext, p *BaseSnapshotDecorator) { |
| 524 | if p.Version() != ctx.DeviceConfig().VndkVersion() { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 525 | ctx.Module().Disable() |
| 526 | return |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | // |
| 531 | // Module definitions for snapshots of libraries (shared, static, header). |
| 532 | // |
| 533 | // Modules (vendor|recovery)_snapshot_(shared|static|header) are defined here. Shared libraries and |
| 534 | // static libraries have their prebuilt library files (.so for shared, .a for static) as their src, |
| 535 | // which can be installed or linked against. Also they export flags needed when linked, such as |
| 536 | // include directories, c flags, sanitize dependency information, etc. |
| 537 | // |
| 538 | // These modules are auto-generated by development/vendor_snapshot/update.py. |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 539 | type SnapshotLibraryProperties struct { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 540 | // Prebuilt file for each arch. |
| 541 | Src *string `android:"arch_variant"` |
| 542 | |
| 543 | // list of directories that will be added to the include path (using -I). |
| 544 | Export_include_dirs []string `android:"arch_variant"` |
| 545 | |
| 546 | // list of directories that will be added to the system path (using -isystem). |
| 547 | Export_system_include_dirs []string `android:"arch_variant"` |
| 548 | |
| 549 | // list of flags that will be used for any module that links against this module. |
| 550 | Export_flags []string `android:"arch_variant"` |
| 551 | |
| 552 | // Whether this prebuilt needs to depend on sanitize ubsan runtime or not. |
| 553 | Sanitize_ubsan_dep *bool `android:"arch_variant"` |
| 554 | |
| 555 | // Whether this prebuilt needs to depend on sanitize minimal runtime or not. |
| 556 | Sanitize_minimal_dep *bool `android:"arch_variant"` |
| 557 | } |
| 558 | |
| 559 | type snapshotSanitizer interface { |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 560 | isSanitizerEnabled(t SanitizerType) bool |
| 561 | setSanitizerVariation(t SanitizerType, enabled bool) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | type snapshotLibraryDecorator struct { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 565 | BaseSnapshotDecorator |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 566 | *libraryDecorator |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 567 | properties SnapshotLibraryProperties |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 568 | sanitizerProperties struct { |
| 569 | CfiEnabled bool `blueprint:"mutated"` |
| 570 | |
| 571 | // Library flags for cfi variant. |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 572 | Cfi SnapshotLibraryProperties `android:"arch_variant"` |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 573 | } |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | func (p *snapshotLibraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags { |
| 577 | p.libraryDecorator.libName = strings.TrimSuffix(ctx.ModuleName(), p.NameSuffix()) |
| 578 | return p.libraryDecorator.linkerFlags(ctx, flags) |
| 579 | } |
| 580 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 581 | func (p *snapshotLibraryDecorator) MatchesWithDevice(config android.DeviceConfig) bool { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 582 | arches := config.Arches() |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 583 | if len(arches) == 0 || arches[0].ArchType.String() != p.Arch() { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 584 | return false |
| 585 | } |
| 586 | if !p.header() && p.properties.Src == nil { |
| 587 | return false |
| 588 | } |
| 589 | return true |
| 590 | } |
| 591 | |
| 592 | // cc modules' link functions are to link compiled objects into final binaries. |
| 593 | // As snapshots are prebuilts, this just returns the prebuilt binary after doing things which are |
| 594 | // done by normal library decorator, e.g. exporting flags. |
| 595 | func (p *snapshotLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { |
Jose Galmes | 7fdc336 | 2021-05-26 21:16:52 -0700 | [diff] [blame] | 596 | var variant string |
| 597 | if p.shared() { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 598 | variant = SnapshotSharedSuffix |
Jose Galmes | 7fdc336 | 2021-05-26 21:16:52 -0700 | [diff] [blame] | 599 | } else if p.static() { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 600 | variant = SnapshotStaticSuffix |
Jose Galmes | 7fdc336 | 2021-05-26 21:16:52 -0700 | [diff] [blame] | 601 | } else { |
| 602 | variant = snapshotHeaderSuffix |
| 603 | } |
| 604 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 605 | p.SetSnapshotAndroidMkSuffix(ctx, variant) |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 606 | |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 607 | if p.header() { |
| 608 | return p.libraryDecorator.link(ctx, flags, deps, objs) |
| 609 | } |
| 610 | |
| 611 | if p.sanitizerProperties.CfiEnabled { |
| 612 | p.properties = p.sanitizerProperties.Cfi |
| 613 | } |
| 614 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 615 | if !p.MatchesWithDevice(ctx.DeviceConfig()) { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 616 | return nil |
| 617 | } |
| 618 | |
Inseob Kim | dd0295d | 2021-04-12 21:09:59 +0900 | [diff] [blame] | 619 | // Flags specified directly to this module. |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 620 | p.libraryDecorator.reexportDirs(android.PathsForModuleSrc(ctx, p.properties.Export_include_dirs)...) |
| 621 | p.libraryDecorator.reexportSystemDirs(android.PathsForModuleSrc(ctx, p.properties.Export_system_include_dirs)...) |
| 622 | p.libraryDecorator.reexportFlags(p.properties.Export_flags...) |
| 623 | |
Inseob Kim | dd0295d | 2021-04-12 21:09:59 +0900 | [diff] [blame] | 624 | // Flags reexported from dependencies. (e.g. vndk_prebuilt_shared) |
| 625 | p.libraryDecorator.reexportDirs(deps.ReexportedDirs...) |
| 626 | p.libraryDecorator.reexportSystemDirs(deps.ReexportedSystemDirs...) |
| 627 | p.libraryDecorator.reexportFlags(deps.ReexportedFlags...) |
| 628 | p.libraryDecorator.reexportDeps(deps.ReexportedDeps...) |
| 629 | p.libraryDecorator.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...) |
| 630 | |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 631 | in := android.PathForModuleSrc(ctx, *p.properties.Src) |
| 632 | p.unstrippedOutputFile = in |
| 633 | |
| 634 | if p.shared() { |
| 635 | libName := in.Base() |
| 636 | builderFlags := flagsToBuilderFlags(flags) |
| 637 | |
| 638 | // Optimize out relinking against shared libraries whose interface hasn't changed by |
| 639 | // depending on a table of contents file instead of the library itself. |
| 640 | tocFile := android.PathForModuleOut(ctx, libName+".toc") |
| 641 | p.tocFile = android.OptionalPathForPath(tocFile) |
| 642 | transformSharedObjectToToc(ctx, in, tocFile, builderFlags) |
| 643 | |
| 644 | ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{ |
| 645 | SharedLibrary: in, |
| 646 | UnstrippedSharedLibrary: p.unstrippedOutputFile, |
Colin Cross | 2df8177 | 2021-01-26 11:00:18 -0800 | [diff] [blame] | 647 | Target: ctx.Target(), |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 648 | |
| 649 | TableOfContents: p.tocFile, |
| 650 | }) |
| 651 | } |
| 652 | |
| 653 | if p.static() { |
| 654 | depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(in).Build() |
| 655 | ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{ |
| 656 | StaticLibrary: in, |
| 657 | |
| 658 | TransitiveStaticLibrariesForOrdering: depSet, |
| 659 | }) |
| 660 | } |
| 661 | |
| 662 | p.libraryDecorator.flagExporter.setProvider(ctx) |
| 663 | |
| 664 | return in |
| 665 | } |
| 666 | |
| 667 | func (p *snapshotLibraryDecorator) install(ctx ModuleContext, file android.Path) { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 668 | if p.MatchesWithDevice(ctx.DeviceConfig()) && (p.shared() || p.static()) { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 669 | p.baseInstaller.install(ctx, file) |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | func (p *snapshotLibraryDecorator) nativeCoverage() bool { |
| 674 | return false |
| 675 | } |
| 676 | |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 677 | func (p *snapshotLibraryDecorator) isSanitizerEnabled(t SanitizerType) bool { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 678 | switch t { |
| 679 | case cfi: |
| 680 | return p.sanitizerProperties.Cfi.Src != nil |
| 681 | default: |
| 682 | return false |
| 683 | } |
| 684 | } |
| 685 | |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 686 | func (p *snapshotLibraryDecorator) setSanitizerVariation(t SanitizerType, enabled bool) { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 687 | if !enabled { |
| 688 | return |
| 689 | } |
| 690 | switch t { |
| 691 | case cfi: |
| 692 | p.sanitizerProperties.CfiEnabled = true |
| 693 | default: |
| 694 | return |
| 695 | } |
| 696 | } |
| 697 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 698 | func snapshotLibraryFactory(image SnapshotImage, moduleSuffix string) (*Module, *snapshotLibraryDecorator) { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 699 | module, library := NewLibrary(android.DeviceSupported) |
| 700 | |
| 701 | module.stl = nil |
| 702 | module.sanitize = nil |
| 703 | library.disableStripping() |
| 704 | |
| 705 | prebuilt := &snapshotLibraryDecorator{ |
| 706 | libraryDecorator: library, |
| 707 | } |
| 708 | |
| 709 | prebuilt.baseLinker.Properties.No_libcrt = BoolPtr(true) |
| 710 | prebuilt.baseLinker.Properties.Nocrt = BoolPtr(true) |
| 711 | |
| 712 | // Prevent default system libs (libc, libm, and libdl) from being linked |
| 713 | if prebuilt.baseLinker.Properties.System_shared_libs == nil { |
| 714 | prebuilt.baseLinker.Properties.System_shared_libs = []string{} |
| 715 | } |
| 716 | |
| 717 | module.compiler = nil |
| 718 | module.linker = prebuilt |
| 719 | module.installer = prebuilt |
| 720 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 721 | prebuilt.Init(module, image, moduleSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 722 | module.AddProperties( |
| 723 | &prebuilt.properties, |
| 724 | &prebuilt.sanitizerProperties, |
| 725 | ) |
| 726 | |
| 727 | return module, prebuilt |
| 728 | } |
| 729 | |
| 730 | // vendor_snapshot_shared is a special prebuilt shared library which is auto-generated by |
| 731 | // development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_shared |
| 732 | // overrides the vendor variant of the cc shared library with the same name, if BOARD_VNDK_VERSION |
| 733 | // is set. |
| 734 | func VendorSnapshotSharedFactory() android.Module { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 735 | module, prebuilt := snapshotLibraryFactory(VendorSnapshotImageSingleton, SnapshotSharedSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 736 | prebuilt.libraryDecorator.BuildOnlyShared() |
| 737 | return module.Init() |
| 738 | } |
| 739 | |
| 740 | // recovery_snapshot_shared is a special prebuilt shared library which is auto-generated by |
| 741 | // development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_shared |
| 742 | // overrides the recovery variant of the cc shared library with the same name, if BOARD_VNDK_VERSION |
| 743 | // is set. |
| 744 | func RecoverySnapshotSharedFactory() android.Module { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 745 | module, prebuilt := snapshotLibraryFactory(recoverySnapshotImageSingleton, SnapshotSharedSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 746 | prebuilt.libraryDecorator.BuildOnlyShared() |
| 747 | return module.Init() |
| 748 | } |
| 749 | |
| 750 | // vendor_snapshot_static is a special prebuilt static library which is auto-generated by |
| 751 | // development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_static |
| 752 | // overrides the vendor variant of the cc static library with the same name, if BOARD_VNDK_VERSION |
| 753 | // is set. |
| 754 | func VendorSnapshotStaticFactory() android.Module { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 755 | module, prebuilt := snapshotLibraryFactory(VendorSnapshotImageSingleton, SnapshotStaticSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 756 | prebuilt.libraryDecorator.BuildOnlyStatic() |
| 757 | return module.Init() |
| 758 | } |
| 759 | |
| 760 | // recovery_snapshot_static is a special prebuilt static library which is auto-generated by |
| 761 | // development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_static |
| 762 | // overrides the recovery variant of the cc static library with the same name, if BOARD_VNDK_VERSION |
| 763 | // is set. |
| 764 | func RecoverySnapshotStaticFactory() android.Module { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 765 | module, prebuilt := snapshotLibraryFactory(recoverySnapshotImageSingleton, SnapshotStaticSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 766 | prebuilt.libraryDecorator.BuildOnlyStatic() |
| 767 | return module.Init() |
| 768 | } |
| 769 | |
| 770 | // vendor_snapshot_header is a special header library which is auto-generated by |
| 771 | // development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_header |
| 772 | // overrides the vendor variant of the cc header library with the same name, if BOARD_VNDK_VERSION |
| 773 | // is set. |
| 774 | func VendorSnapshotHeaderFactory() android.Module { |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 775 | module, prebuilt := snapshotLibraryFactory(VendorSnapshotImageSingleton, snapshotHeaderSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 776 | prebuilt.libraryDecorator.HeaderOnly() |
| 777 | return module.Init() |
| 778 | } |
| 779 | |
| 780 | // recovery_snapshot_header is a special header library which is auto-generated by |
| 781 | // development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_header |
| 782 | // overrides the recovery variant of the cc header library with the same name, if BOARD_VNDK_VERSION |
| 783 | // is set. |
| 784 | func RecoverySnapshotHeaderFactory() android.Module { |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 785 | module, prebuilt := snapshotLibraryFactory(recoverySnapshotImageSingleton, snapshotHeaderSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 786 | prebuilt.libraryDecorator.HeaderOnly() |
| 787 | return module.Init() |
| 788 | } |
| 789 | |
| 790 | var _ snapshotSanitizer = (*snapshotLibraryDecorator)(nil) |
| 791 | |
| 792 | // |
| 793 | // Module definitions for snapshots of executable binaries. |
| 794 | // |
| 795 | // Modules (vendor|recovery)_snapshot_binary are defined here. They have their prebuilt executable |
| 796 | // binaries (e.g. toybox, sh) as their src, which can be installed. |
| 797 | // |
| 798 | // These modules are auto-generated by development/vendor_snapshot/update.py. |
| 799 | type snapshotBinaryProperties struct { |
| 800 | // Prebuilt file for each arch. |
| 801 | Src *string `android:"arch_variant"` |
| 802 | } |
| 803 | |
| 804 | type snapshotBinaryDecorator struct { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 805 | BaseSnapshotDecorator |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 806 | *binaryDecorator |
Colin Cross | a889080 | 2021-01-22 14:06:33 -0800 | [diff] [blame] | 807 | properties snapshotBinaryProperties |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 808 | } |
| 809 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 810 | func (p *snapshotBinaryDecorator) MatchesWithDevice(config android.DeviceConfig) bool { |
| 811 | if config.DeviceArch() != p.Arch() { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 812 | return false |
| 813 | } |
| 814 | if p.properties.Src == nil { |
| 815 | return false |
| 816 | } |
| 817 | return true |
| 818 | } |
| 819 | |
| 820 | // cc modules' link functions are to link compiled objects into final binaries. |
| 821 | // As snapshots are prebuilts, this just returns the prebuilt binary |
| 822 | func (p *snapshotBinaryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 823 | p.SetSnapshotAndroidMkSuffix(ctx, snapshotBinarySuffix) |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 824 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 825 | if !p.MatchesWithDevice(ctx.DeviceConfig()) { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 826 | return nil |
| 827 | } |
| 828 | |
| 829 | in := android.PathForModuleSrc(ctx, *p.properties.Src) |
| 830 | p.unstrippedOutputFile = in |
| 831 | binName := in.Base() |
| 832 | |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 833 | // use cpExecutable to make it executable |
| 834 | outputFile := android.PathForModuleOut(ctx, binName) |
| 835 | ctx.Build(pctx, android.BuildParams{ |
| 836 | Rule: android.CpExecutable, |
| 837 | Description: "prebuilt", |
| 838 | Output: outputFile, |
| 839 | Input: in, |
| 840 | }) |
| 841 | |
| 842 | return outputFile |
| 843 | } |
| 844 | |
| 845 | func (p *snapshotBinaryDecorator) nativeCoverage() bool { |
| 846 | return false |
| 847 | } |
| 848 | |
| 849 | // vendor_snapshot_binary is a special prebuilt executable binary which is auto-generated by |
| 850 | // development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_binary |
| 851 | // overrides the vendor variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set. |
| 852 | func VendorSnapshotBinaryFactory() android.Module { |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 853 | return snapshotBinaryFactory(VendorSnapshotImageSingleton, snapshotBinarySuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | // recovery_snapshot_binary is a special prebuilt executable binary which is auto-generated by |
| 857 | // development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_binary |
| 858 | // overrides the recovery variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set. |
| 859 | func RecoverySnapshotBinaryFactory() android.Module { |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 860 | return snapshotBinaryFactory(recoverySnapshotImageSingleton, snapshotBinarySuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 861 | } |
| 862 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 863 | func snapshotBinaryFactory(image SnapshotImage, moduleSuffix string) android.Module { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 864 | module, binary := NewBinary(android.DeviceSupported) |
| 865 | binary.baseLinker.Properties.No_libcrt = BoolPtr(true) |
| 866 | binary.baseLinker.Properties.Nocrt = BoolPtr(true) |
| 867 | |
| 868 | // Prevent default system libs (libc, libm, and libdl) from being linked |
| 869 | if binary.baseLinker.Properties.System_shared_libs == nil { |
| 870 | binary.baseLinker.Properties.System_shared_libs = []string{} |
| 871 | } |
| 872 | |
| 873 | prebuilt := &snapshotBinaryDecorator{ |
| 874 | binaryDecorator: binary, |
| 875 | } |
| 876 | |
| 877 | module.compiler = nil |
| 878 | module.sanitize = nil |
| 879 | module.stl = nil |
| 880 | module.linker = prebuilt |
| 881 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 882 | prebuilt.Init(module, image, moduleSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 883 | module.AddProperties(&prebuilt.properties) |
| 884 | return module.Init() |
| 885 | } |
| 886 | |
| 887 | // |
| 888 | // Module definitions for snapshots of object files (*.o). |
| 889 | // |
| 890 | // Modules (vendor|recovery)_snapshot_object are defined here. They have their prebuilt object |
| 891 | // files (*.o) as their src. |
| 892 | // |
| 893 | // These modules are auto-generated by development/vendor_snapshot/update.py. |
| 894 | type vendorSnapshotObjectProperties struct { |
| 895 | // Prebuilt file for each arch. |
| 896 | Src *string `android:"arch_variant"` |
| 897 | } |
| 898 | |
| 899 | type snapshotObjectLinker struct { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 900 | BaseSnapshotDecorator |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 901 | objectLinker |
Colin Cross | a889080 | 2021-01-22 14:06:33 -0800 | [diff] [blame] | 902 | properties vendorSnapshotObjectProperties |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 903 | } |
| 904 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 905 | func (p *snapshotObjectLinker) MatchesWithDevice(config android.DeviceConfig) bool { |
| 906 | if config.DeviceArch() != p.Arch() { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 907 | return false |
| 908 | } |
| 909 | if p.properties.Src == nil { |
| 910 | return false |
| 911 | } |
| 912 | return true |
| 913 | } |
| 914 | |
| 915 | // cc modules' link functions are to link compiled objects into final binaries. |
| 916 | // As snapshots are prebuilts, this just returns the prebuilt binary |
| 917 | func (p *snapshotObjectLinker) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 918 | p.SetSnapshotAndroidMkSuffix(ctx, snapshotObjectSuffix) |
Inseob Kim | 1b6fb87 | 2021-04-05 13:37:02 +0900 | [diff] [blame] | 919 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 920 | if !p.MatchesWithDevice(ctx.DeviceConfig()) { |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 921 | return nil |
| 922 | } |
| 923 | |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 924 | return android.PathForModuleSrc(ctx, *p.properties.Src) |
| 925 | } |
| 926 | |
| 927 | func (p *snapshotObjectLinker) nativeCoverage() bool { |
| 928 | return false |
| 929 | } |
| 930 | |
| 931 | // vendor_snapshot_object is a special prebuilt compiled object file which is auto-generated by |
| 932 | // development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_object |
| 933 | // overrides the vendor variant of the cc object with the same name, if BOARD_VNDK_VERSION is set. |
| 934 | func VendorSnapshotObjectFactory() android.Module { |
| 935 | module := newObject() |
| 936 | |
| 937 | prebuilt := &snapshotObjectLinker{ |
| 938 | objectLinker: objectLinker{ |
| 939 | baseLinker: NewBaseLinker(nil), |
| 940 | }, |
| 941 | } |
| 942 | module.linker = prebuilt |
| 943 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 944 | prebuilt.Init(module, VendorSnapshotImageSingleton, snapshotObjectSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 945 | module.AddProperties(&prebuilt.properties) |
| 946 | return module.Init() |
| 947 | } |
| 948 | |
| 949 | // recovery_snapshot_object is a special prebuilt compiled object file which is auto-generated by |
| 950 | // development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_object |
| 951 | // overrides the recovery variant of the cc object with the same name, if BOARD_VNDK_VERSION is set. |
| 952 | func RecoverySnapshotObjectFactory() android.Module { |
| 953 | module := newObject() |
| 954 | |
| 955 | prebuilt := &snapshotObjectLinker{ |
| 956 | objectLinker: objectLinker{ |
| 957 | baseLinker: NewBaseLinker(nil), |
| 958 | }, |
| 959 | } |
| 960 | module.linker = prebuilt |
| 961 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 962 | prebuilt.Init(module, recoverySnapshotImageSingleton, snapshotObjectSuffix) |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 963 | module.AddProperties(&prebuilt.properties) |
| 964 | return module.Init() |
| 965 | } |
| 966 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 967 | type SnapshotInterface interface { |
| 968 | MatchesWithDevice(config android.DeviceConfig) bool |
| 969 | IsSnapshotPrebuilt() bool |
| 970 | Version() string |
| 971 | SnapshotAndroidMkSuffix() string |
Inseob Kim | de5744a | 2020-12-02 13:14:28 +0900 | [diff] [blame] | 972 | } |
| 973 | |
Ivan Lozano | d1dec54 | 2021-05-26 15:33:11 -0400 | [diff] [blame] | 974 | var _ SnapshotInterface = (*vndkPrebuiltLibraryDecorator)(nil) |
| 975 | var _ SnapshotInterface = (*snapshotLibraryDecorator)(nil) |
| 976 | var _ SnapshotInterface = (*snapshotBinaryDecorator)(nil) |
| 977 | var _ SnapshotInterface = (*snapshotObjectLinker)(nil) |