blob: 9d40ad0584db459733fb7d31e4b161693c102470 [file] [log] [blame]
Inseob Kimde5744a2020-12-02 13:14:28 +09001// 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.
14package 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
20import (
21 "strings"
Inseob Kimde5744a2020-12-02 13:14:28 +090022
23 "android/soong/android"
Kiyoung Kim48f37782021-07-07 12:42:39 +090024 "android/soong/snapshot"
Jose Galmes6f843bc2020-12-11 13:36:29 -080025
Colin Crosse0edaf92021-01-11 17:31:17 -080026 "github.com/google/blueprint"
Inseob Kimde5744a2020-12-02 13:14:28 +090027)
28
Kiyoung Kim48f37782021-07-07 12:42:39 +090029// This interface overrides snapshot.SnapshotImage to implement cc module specific functions
Ivan Lozanod1dec542021-05-26 15:33:11 -040030type SnapshotImage interface {
Kiyoung Kim48f37782021-07-07 12:42:39 +090031 snapshot.SnapshotImage
Colin Crosse0edaf92021-01-11 17:31:17 -080032
33 // The image variant name for this snapshot image.
34 // For example, recovery snapshot image will return "recovery", and vendor snapshot image will
35 // return "vendor." + version.
36 imageVariantName(cfg android.DeviceConfig) string
37
38 // The variant suffix for snapshot modules. For example, vendor snapshot modules will have
39 // ".vendor" as their suffix.
40 moduleNameSuffix() string
Inseob Kimde5744a2020-12-02 13:14:28 +090041}
42
Kiyoung Kim48f37782021-07-07 12:42:39 +090043type vendorSnapshotImage struct {
44 *snapshot.VendorSnapshotImage
Inseob Kimde5744a2020-12-02 13:14:28 +090045}
46
Kiyoung Kim48f37782021-07-07 12:42:39 +090047type recoverySnapshotImage struct {
48 *snapshot.RecoverySnapshotImage
Inseob Kim7cf14652021-01-06 23:06:52 +090049}
50
Colin Crosse0edaf92021-01-11 17:31:17 -080051func (vendorSnapshotImage) imageVariantName(cfg android.DeviceConfig) string {
52 return VendorVariationPrefix + cfg.VndkVersion()
53}
54
55func (vendorSnapshotImage) moduleNameSuffix() string {
Ivan Lozanoe6d30982021-02-05 10:57:43 -050056 return VendorSuffix
Colin Crosse0edaf92021-01-11 17:31:17 -080057}
58
Colin Crosse0edaf92021-01-11 17:31:17 -080059func (recoverySnapshotImage) imageVariantName(cfg android.DeviceConfig) string {
60 return android.RecoveryVariation
61}
62
63func (recoverySnapshotImage) moduleNameSuffix() string {
Matthew Maurer460ee942021-02-11 12:31:46 -080064 return RecoverySuffix
Colin Crosse0edaf92021-01-11 17:31:17 -080065}
66
Kiyoung Kim48f37782021-07-07 12:42:39 +090067// Override existing vendor and recovery snapshot for cc module specific extra functions
68var VendorSnapshotImageSingleton vendorSnapshotImage = vendorSnapshotImage{&snapshot.VendorSnapshotImageSingleton}
Jose Galmesd7d99be2021-11-05 14:04:54 -070069var RecoverySnapshotImageSingleton recoverySnapshotImage = recoverySnapshotImage{&snapshot.RecoverySnapshotImageSingleton}
Kiyoung Kim48f37782021-07-07 12:42:39 +090070
71func RegisterVendorSnapshotModules(ctx android.RegistrationContext) {
72 ctx.RegisterModuleType("vendor_snapshot", vendorSnapshotFactory)
73 ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
74 ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
75 ctx.RegisterModuleType("vendor_snapshot_header", VendorSnapshotHeaderFactory)
76 ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
77 ctx.RegisterModuleType("vendor_snapshot_object", VendorSnapshotObjectFactory)
78}
79
80func RegisterRecoverySnapshotModules(ctx android.RegistrationContext) {
81 ctx.RegisterModuleType("recovery_snapshot", recoverySnapshotFactory)
82 ctx.RegisterModuleType("recovery_snapshot_shared", RecoverySnapshotSharedFactory)
83 ctx.RegisterModuleType("recovery_snapshot_static", RecoverySnapshotStaticFactory)
84 ctx.RegisterModuleType("recovery_snapshot_header", RecoverySnapshotHeaderFactory)
85 ctx.RegisterModuleType("recovery_snapshot_binary", RecoverySnapshotBinaryFactory)
86 ctx.RegisterModuleType("recovery_snapshot_object", RecoverySnapshotObjectFactory)
87}
Inseob Kimde5744a2020-12-02 13:14:28 +090088
89func init() {
Kiyoung Kim48f37782021-07-07 12:42:39 +090090 RegisterVendorSnapshotModules(android.InitRegistrationContext)
91 RegisterRecoverySnapshotModules(android.InitRegistrationContext)
Justin Yund9e05752021-07-13 11:36:24 +090092 android.RegisterMakeVarsProvider(pctx, snapshotMakeVarsProvider)
Inseob Kimde5744a2020-12-02 13:14:28 +090093}
94
95const (
Colin Crosse0edaf92021-01-11 17:31:17 -080096 snapshotHeaderSuffix = "_header."
Ivan Lozanod1dec542021-05-26 15:33:11 -040097 SnapshotSharedSuffix = "_shared."
98 SnapshotStaticSuffix = "_static."
Colin Crosse0edaf92021-01-11 17:31:17 -080099 snapshotBinarySuffix = "_binary."
100 snapshotObjectSuffix = "_object."
Ivan Lozano3149e6e2021-06-01 15:09:53 -0400101 SnapshotRlibSuffix = "_rlib."
Inseob Kimde5744a2020-12-02 13:14:28 +0900102)
103
Colin Crosse0edaf92021-01-11 17:31:17 -0800104type SnapshotProperties struct {
105 Header_libs []string `android:"arch_variant"`
106 Static_libs []string `android:"arch_variant"`
107 Shared_libs []string `android:"arch_variant"`
Ivan Lozano3149e6e2021-06-01 15:09:53 -0400108 Rlibs []string `android:"arch_variant"`
Colin Crosse0edaf92021-01-11 17:31:17 -0800109 Vndk_libs []string `android:"arch_variant"`
110 Binaries []string `android:"arch_variant"`
111 Objects []string `android:"arch_variant"`
112}
Kiyoung Kim48f37782021-07-07 12:42:39 +0900113type snapshotModule struct {
Colin Crosse0edaf92021-01-11 17:31:17 -0800114 android.ModuleBase
115
116 properties SnapshotProperties
117
Ivan Lozanod1dec542021-05-26 15:33:11 -0400118 baseSnapshot BaseSnapshotDecorator
Colin Crosse0edaf92021-01-11 17:31:17 -0800119
Ivan Lozanod1dec542021-05-26 15:33:11 -0400120 image SnapshotImage
Colin Crosse0edaf92021-01-11 17:31:17 -0800121}
122
Kiyoung Kim48f37782021-07-07 12:42:39 +0900123func (s *snapshotModule) ImageMutatorBegin(ctx android.BaseModuleContext) {
Colin Crosse0edaf92021-01-11 17:31:17 -0800124 cfg := ctx.DeviceConfig()
Kiyoung Kim48f37782021-07-07 12:42:39 +0900125 if !s.image.IsUsingSnapshot(cfg) || s.image.TargetSnapshotVersion(cfg) != s.baseSnapshot.Version() {
Colin Crosse0edaf92021-01-11 17:31:17 -0800126 s.Disable()
127 }
128}
129
Kiyoung Kim48f37782021-07-07 12:42:39 +0900130func (s *snapshotModule) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
Colin Crosse0edaf92021-01-11 17:31:17 -0800131 return false
132}
133
Kiyoung Kim48f37782021-07-07 12:42:39 +0900134func (s *snapshotModule) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
Colin Crosse0edaf92021-01-11 17:31:17 -0800135 return false
136}
137
Kiyoung Kim48f37782021-07-07 12:42:39 +0900138func (s *snapshotModule) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
Colin Crosse0edaf92021-01-11 17:31:17 -0800139 return false
140}
141
Kiyoung Kim48f37782021-07-07 12:42:39 +0900142func (s *snapshotModule) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900143 return false
144}
145
Kiyoung Kim48f37782021-07-07 12:42:39 +0900146func (s *snapshotModule) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
Colin Crosse0edaf92021-01-11 17:31:17 -0800147 return false
148}
149
Kiyoung Kim48f37782021-07-07 12:42:39 +0900150func (s *snapshotModule) ExtraImageVariations(ctx android.BaseModuleContext) []string {
Colin Crosse0edaf92021-01-11 17:31:17 -0800151 return []string{s.image.imageVariantName(ctx.DeviceConfig())}
152}
153
Kiyoung Kim48f37782021-07-07 12:42:39 +0900154func (s *snapshotModule) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
Colin Crosse0edaf92021-01-11 17:31:17 -0800155}
156
Kiyoung Kim48f37782021-07-07 12:42:39 +0900157func (s *snapshotModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Crosse0edaf92021-01-11 17:31:17 -0800158 // Nothing, the snapshot module is only used to forward dependency information in DepsMutator.
159}
160
Justin Yun07b9f862021-02-26 14:00:03 +0900161func getSnapshotNameSuffix(moduleSuffix, version, arch string) string {
162 versionSuffix := version
163 if arch != "" {
164 versionSuffix += "." + arch
165 }
166 return moduleSuffix + versionSuffix
167}
Colin Crosse0edaf92021-01-11 17:31:17 -0800168
Kiyoung Kim48f37782021-07-07 12:42:39 +0900169func (s *snapshotModule) DepsMutator(ctx android.BottomUpMutatorContext) {
Justin Yun07b9f862021-02-26 14:00:03 +0900170 collectSnapshotMap := func(names []string, snapshotSuffix, moduleSuffix string) map[string]string {
Colin Crosse0edaf92021-01-11 17:31:17 -0800171 snapshotMap := make(map[string]string)
Justin Yun48138672021-02-25 18:21:27 +0900172 for _, name := range names {
173 snapshotMap[name] = name +
Justin Yun07b9f862021-02-26 14:00:03 +0900174 getSnapshotNameSuffix(snapshotSuffix+moduleSuffix,
Ivan Lozanod1dec542021-05-26 15:33:11 -0400175 s.baseSnapshot.Version(),
Jose Galmesf9523ed2021-04-06 19:48:10 -0700176 ctx.DeviceConfig().Arches()[0].ArchType.String())
Colin Crosse0edaf92021-01-11 17:31:17 -0800177 }
178 return snapshotMap
179 }
180
181 snapshotSuffix := s.image.moduleNameSuffix()
Justin Yun07b9f862021-02-26 14:00:03 +0900182 headers := collectSnapshotMap(s.properties.Header_libs, snapshotSuffix, snapshotHeaderSuffix)
183 binaries := collectSnapshotMap(s.properties.Binaries, snapshotSuffix, snapshotBinarySuffix)
184 objects := collectSnapshotMap(s.properties.Objects, snapshotSuffix, snapshotObjectSuffix)
Ivan Lozanod1dec542021-05-26 15:33:11 -0400185 staticLibs := collectSnapshotMap(s.properties.Static_libs, snapshotSuffix, SnapshotStaticSuffix)
186 sharedLibs := collectSnapshotMap(s.properties.Shared_libs, snapshotSuffix, SnapshotSharedSuffix)
Ivan Lozano3149e6e2021-06-01 15:09:53 -0400187 rlibs := collectSnapshotMap(s.properties.Rlibs, snapshotSuffix, SnapshotRlibSuffix)
Justin Yun07b9f862021-02-26 14:00:03 +0900188 vndkLibs := collectSnapshotMap(s.properties.Vndk_libs, "", vndkSuffix)
Colin Crosse0edaf92021-01-11 17:31:17 -0800189 for k, v := range vndkLibs {
190 sharedLibs[k] = v
191 }
Justin Yun07b9f862021-02-26 14:00:03 +0900192
Colin Crosse0edaf92021-01-11 17:31:17 -0800193 ctx.SetProvider(SnapshotInfoProvider, SnapshotInfo{
194 HeaderLibs: headers,
195 Binaries: binaries,
196 Objects: objects,
197 StaticLibs: staticLibs,
198 SharedLibs: sharedLibs,
Ivan Lozano3149e6e2021-06-01 15:09:53 -0400199 Rlibs: rlibs,
Colin Crosse0edaf92021-01-11 17:31:17 -0800200 })
201}
202
203type SnapshotInfo struct {
Ivan Lozano3149e6e2021-06-01 15:09:53 -0400204 HeaderLibs, Binaries, Objects, StaticLibs, SharedLibs, Rlibs map[string]string
Colin Crosse0edaf92021-01-11 17:31:17 -0800205}
206
207var SnapshotInfoProvider = blueprint.NewMutatorProvider(SnapshotInfo{}, "deps")
208
Kiyoung Kim48f37782021-07-07 12:42:39 +0900209var _ android.ImageInterface = (*snapshotModule)(nil)
Colin Crosse0edaf92021-01-11 17:31:17 -0800210
Justin Yund9e05752021-07-13 11:36:24 +0900211func snapshotMakeVarsProvider(ctx android.MakeVarsContext) {
212 snapshotSet := map[string]struct{}{}
213 ctx.VisitAllModules(func(m android.Module) {
Kiyoung Kim48f37782021-07-07 12:42:39 +0900214 if s, ok := m.(*snapshotModule); ok {
Justin Yund9e05752021-07-13 11:36:24 +0900215 if _, ok := snapshotSet[s.Name()]; ok {
216 // arch variant generates duplicated modules
217 // skip this as we only need to know the path of the module.
218 return
219 }
220 snapshotSet[s.Name()] = struct{}{}
221 imageNameVersion := strings.Split(s.image.imageVariantName(ctx.DeviceConfig()), ".")
222 ctx.Strict(
223 strings.Join([]string{strings.ToUpper(imageNameVersion[0]), s.baseSnapshot.Version(), "SNAPSHOT_DIR"}, "_"),
224 ctx.ModuleDir(s))
225 }
226 })
227}
228
Colin Crosse0edaf92021-01-11 17:31:17 -0800229func vendorSnapshotFactory() android.Module {
Ivan Lozanod67a6b02021-05-20 13:01:32 -0400230 return snapshotFactory(VendorSnapshotImageSingleton)
Colin Crosse0edaf92021-01-11 17:31:17 -0800231}
232
233func recoverySnapshotFactory() android.Module {
Jose Galmesd7d99be2021-11-05 14:04:54 -0700234 return snapshotFactory(RecoverySnapshotImageSingleton)
Colin Crosse0edaf92021-01-11 17:31:17 -0800235}
236
Ivan Lozanod1dec542021-05-26 15:33:11 -0400237func snapshotFactory(image SnapshotImage) android.Module {
Kiyoung Kim48f37782021-07-07 12:42:39 +0900238 snapshotModule := &snapshotModule{}
239 snapshotModule.image = image
240 snapshotModule.AddProperties(
241 &snapshotModule.properties,
242 &snapshotModule.baseSnapshot.baseProperties)
243 android.InitAndroidArchModule(snapshotModule, android.DeviceSupported, android.MultilibBoth)
244 return snapshotModule
Colin Crosse0edaf92021-01-11 17:31:17 -0800245}
246
Ivan Lozanod1dec542021-05-26 15:33:11 -0400247type BaseSnapshotDecoratorProperties struct {
Inseob Kimde5744a2020-12-02 13:14:28 +0900248 // snapshot version.
249 Version string
250
251 // Target arch name of the snapshot (e.g. 'arm64' for variant 'aosp_arm64')
252 Target_arch string
Jose Galmes6f843bc2020-12-11 13:36:29 -0800253
Colin Crossa8890802021-01-22 14:06:33 -0800254 // Suffix to be added to the module name when exporting to Android.mk, e.g. ".vendor".
Inseob Kim1b6fb872021-04-05 13:37:02 +0900255 Androidmk_suffix string `blueprint:"mutated"`
Colin Crossa8890802021-01-22 14:06:33 -0800256
Jose Galmes6f843bc2020-12-11 13:36:29 -0800257 // Suffix to be added to the module name, e.g., vendor_shared,
258 // recovery_shared, etc.
Colin Crosse0edaf92021-01-11 17:31:17 -0800259 ModuleSuffix string `blueprint:"mutated"`
Inseob Kimde5744a2020-12-02 13:14:28 +0900260}
261
Ivan Lozanod1dec542021-05-26 15:33:11 -0400262// BaseSnapshotDecorator provides common basic functions for all snapshot modules, such as snapshot
Inseob Kimde5744a2020-12-02 13:14:28 +0900263// version, snapshot arch, etc. It also adds a special suffix to Soong module name, so it doesn't
264// collide with source modules. e.g. the following example module,
265//
266// vendor_snapshot_static {
267// name: "libbase",
268// arch: "arm64",
269// version: 30,
270// ...
271// }
272//
273// will be seen as "libbase.vendor_static.30.arm64" by Soong.
Ivan Lozanod1dec542021-05-26 15:33:11 -0400274type BaseSnapshotDecorator struct {
275 baseProperties BaseSnapshotDecoratorProperties
Kiyoung Kim48f37782021-07-07 12:42:39 +0900276 Image SnapshotImage
Inseob Kimde5744a2020-12-02 13:14:28 +0900277}
278
Ivan Lozanod1dec542021-05-26 15:33:11 -0400279func (p *BaseSnapshotDecorator) Name(name string) string {
Inseob Kimde5744a2020-12-02 13:14:28 +0900280 return name + p.NameSuffix()
281}
282
Ivan Lozanod1dec542021-05-26 15:33:11 -0400283func (p *BaseSnapshotDecorator) NameSuffix() string {
284 return getSnapshotNameSuffix(p.moduleSuffix(), p.Version(), p.Arch())
Inseob Kimde5744a2020-12-02 13:14:28 +0900285}
286
Ivan Lozanod1dec542021-05-26 15:33:11 -0400287func (p *BaseSnapshotDecorator) Version() string {
Inseob Kimde5744a2020-12-02 13:14:28 +0900288 return p.baseProperties.Version
289}
290
Ivan Lozanod1dec542021-05-26 15:33:11 -0400291func (p *BaseSnapshotDecorator) Arch() string {
Inseob Kimde5744a2020-12-02 13:14:28 +0900292 return p.baseProperties.Target_arch
293}
294
Ivan Lozanod1dec542021-05-26 15:33:11 -0400295func (p *BaseSnapshotDecorator) moduleSuffix() string {
Colin Crosse0edaf92021-01-11 17:31:17 -0800296 return p.baseProperties.ModuleSuffix
Jose Galmes6f843bc2020-12-11 13:36:29 -0800297}
298
Ivan Lozanod1dec542021-05-26 15:33:11 -0400299func (p *BaseSnapshotDecorator) IsSnapshotPrebuilt() bool {
Inseob Kimde5744a2020-12-02 13:14:28 +0900300 return true
301}
302
Ivan Lozanod1dec542021-05-26 15:33:11 -0400303func (p *BaseSnapshotDecorator) SnapshotAndroidMkSuffix() string {
Colin Crossa8890802021-01-22 14:06:33 -0800304 return p.baseProperties.Androidmk_suffix
305}
306
Ivan Lozanod1dec542021-05-26 15:33:11 -0400307func (p *BaseSnapshotDecorator) SetSnapshotAndroidMkSuffix(ctx android.ModuleContext, variant string) {
Jose Galmes7fdc3362021-05-26 21:16:52 -0700308 // If there are any 2 or more variations among {core, product, vendor, recovery}
309 // we have to add the androidmk suffix to avoid duplicate modules with the same
310 // name.
311 variations := append(ctx.Target().Variations(), blueprint.Variation{
Bill Peckham4016d7b2021-05-20 11:54:21 -0700312 Mutator: "image",
313 Variation: android.CoreVariation})
314
Ivan Lozanod1dec542021-05-26 15:33:11 -0400315 if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(LinkableInterface).BaseModuleName()) {
Kiyoung Kim48f37782021-07-07 12:42:39 +0900316 p.baseProperties.Androidmk_suffix = p.Image.moduleNameSuffix()
Bill Peckham4016d7b2021-05-20 11:54:21 -0700317 return
Inseob Kim1b6fb872021-04-05 13:37:02 +0900318 }
Bill Peckham4016d7b2021-05-20 11:54:21 -0700319
Jose Galmes7fdc3362021-05-26 21:16:52 -0700320 variations = append(ctx.Target().Variations(), blueprint.Variation{
Bill Peckham4016d7b2021-05-20 11:54:21 -0700321 Mutator: "image",
322 Variation: ProductVariationPrefix + ctx.DeviceConfig().PlatformVndkVersion()})
323
Ivan Lozanod1dec542021-05-26 15:33:11 -0400324 if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(LinkableInterface).BaseModuleName()) {
Kiyoung Kim48f37782021-07-07 12:42:39 +0900325 p.baseProperties.Androidmk_suffix = p.Image.moduleNameSuffix()
Bill Peckham4016d7b2021-05-20 11:54:21 -0700326 return
327 }
328
Jose Galmesd7d99be2021-11-05 14:04:54 -0700329 images := []SnapshotImage{VendorSnapshotImageSingleton, RecoverySnapshotImageSingleton}
Jose Galmes7fdc3362021-05-26 21:16:52 -0700330
331 for _, image := range images {
Kiyoung Kim48f37782021-07-07 12:42:39 +0900332 if p.Image == image {
Jose Galmes7fdc3362021-05-26 21:16:52 -0700333 continue
334 }
335 variations = append(ctx.Target().Variations(), blueprint.Variation{
336 Mutator: "image",
337 Variation: image.imageVariantName(ctx.DeviceConfig())})
338
339 if ctx.OtherModuleFarDependencyVariantExists(variations,
Ivan Lozanod1dec542021-05-26 15:33:11 -0400340 ctx.Module().(LinkableInterface).BaseModuleName()+
Jose Galmes7fdc3362021-05-26 21:16:52 -0700341 getSnapshotNameSuffix(
342 image.moduleNameSuffix()+variant,
Ivan Lozanod1dec542021-05-26 15:33:11 -0400343 p.Version(),
Jose Galmes7fdc3362021-05-26 21:16:52 -0700344 ctx.DeviceConfig().Arches()[0].ArchType.String())) {
Kiyoung Kim48f37782021-07-07 12:42:39 +0900345 p.baseProperties.Androidmk_suffix = p.Image.moduleNameSuffix()
Jose Galmes7fdc3362021-05-26 21:16:52 -0700346 return
347 }
348 }
349
Bill Peckham4016d7b2021-05-20 11:54:21 -0700350 p.baseProperties.Androidmk_suffix = ""
Inseob Kim1b6fb872021-04-05 13:37:02 +0900351}
352
Inseob Kimde5744a2020-12-02 13:14:28 +0900353// Call this with a module suffix after creating a snapshot module, such as
354// vendorSnapshotSharedSuffix, recoverySnapshotBinarySuffix, etc.
Ivan Lozanod1dec542021-05-26 15:33:11 -0400355func (p *BaseSnapshotDecorator) Init(m LinkableInterface, image SnapshotImage, moduleSuffix string) {
Kiyoung Kim48f37782021-07-07 12:42:39 +0900356 p.Image = image
Inseob Kim1b6fb872021-04-05 13:37:02 +0900357 p.baseProperties.ModuleSuffix = image.moduleNameSuffix() + moduleSuffix
Inseob Kimde5744a2020-12-02 13:14:28 +0900358 m.AddProperties(&p.baseProperties)
359 android.AddLoadHook(m, func(ctx android.LoadHookContext) {
360 vendorSnapshotLoadHook(ctx, p)
361 })
362}
363
364// vendorSnapshotLoadHook disables snapshots if it's not BOARD_VNDK_VERSION.
365// As vendor snapshot is only for vendor, such modules won't be used at all.
Ivan Lozanod1dec542021-05-26 15:33:11 -0400366func vendorSnapshotLoadHook(ctx android.LoadHookContext, p *BaseSnapshotDecorator) {
367 if p.Version() != ctx.DeviceConfig().VndkVersion() {
Inseob Kimde5744a2020-12-02 13:14:28 +0900368 ctx.Module().Disable()
369 return
370 }
371}
372
373//
374// Module definitions for snapshots of libraries (shared, static, header).
375//
376// Modules (vendor|recovery)_snapshot_(shared|static|header) are defined here. Shared libraries and
377// static libraries have their prebuilt library files (.so for shared, .a for static) as their src,
378// which can be installed or linked against. Also they export flags needed when linked, such as
379// include directories, c flags, sanitize dependency information, etc.
380//
381// These modules are auto-generated by development/vendor_snapshot/update.py.
Ivan Lozanod1dec542021-05-26 15:33:11 -0400382type SnapshotLibraryProperties struct {
Inseob Kimde5744a2020-12-02 13:14:28 +0900383 // Prebuilt file for each arch.
384 Src *string `android:"arch_variant"`
385
386 // list of directories that will be added to the include path (using -I).
387 Export_include_dirs []string `android:"arch_variant"`
388
389 // list of directories that will be added to the system path (using -isystem).
390 Export_system_include_dirs []string `android:"arch_variant"`
391
392 // list of flags that will be used for any module that links against this module.
393 Export_flags []string `android:"arch_variant"`
394
395 // Whether this prebuilt needs to depend on sanitize ubsan runtime or not.
396 Sanitize_ubsan_dep *bool `android:"arch_variant"`
397
398 // Whether this prebuilt needs to depend on sanitize minimal runtime or not.
399 Sanitize_minimal_dep *bool `android:"arch_variant"`
400}
401
402type snapshotSanitizer interface {
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500403 isSanitizerEnabled(t SanitizerType) bool
404 setSanitizerVariation(t SanitizerType, enabled bool)
Inseob Kimde5744a2020-12-02 13:14:28 +0900405}
406
407type snapshotLibraryDecorator struct {
Ivan Lozanod1dec542021-05-26 15:33:11 -0400408 BaseSnapshotDecorator
Inseob Kimde5744a2020-12-02 13:14:28 +0900409 *libraryDecorator
Ivan Lozanod1dec542021-05-26 15:33:11 -0400410 properties SnapshotLibraryProperties
Inseob Kimde5744a2020-12-02 13:14:28 +0900411 sanitizerProperties struct {
412 CfiEnabled bool `blueprint:"mutated"`
413
414 // Library flags for cfi variant.
Ivan Lozanod1dec542021-05-26 15:33:11 -0400415 Cfi SnapshotLibraryProperties `android:"arch_variant"`
Inseob Kimde5744a2020-12-02 13:14:28 +0900416 }
Inseob Kimde5744a2020-12-02 13:14:28 +0900417}
418
419func (p *snapshotLibraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
420 p.libraryDecorator.libName = strings.TrimSuffix(ctx.ModuleName(), p.NameSuffix())
421 return p.libraryDecorator.linkerFlags(ctx, flags)
422}
423
Ivan Lozanod1dec542021-05-26 15:33:11 -0400424func (p *snapshotLibraryDecorator) MatchesWithDevice(config android.DeviceConfig) bool {
Inseob Kimde5744a2020-12-02 13:14:28 +0900425 arches := config.Arches()
Ivan Lozanod1dec542021-05-26 15:33:11 -0400426 if len(arches) == 0 || arches[0].ArchType.String() != p.Arch() {
Inseob Kimde5744a2020-12-02 13:14:28 +0900427 return false
428 }
429 if !p.header() && p.properties.Src == nil {
430 return false
431 }
432 return true
433}
434
435// cc modules' link functions are to link compiled objects into final binaries.
436// As snapshots are prebuilts, this just returns the prebuilt binary after doing things which are
437// done by normal library decorator, e.g. exporting flags.
438func (p *snapshotLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
Jose Galmes7fdc3362021-05-26 21:16:52 -0700439 var variant string
440 if p.shared() {
Ivan Lozanod1dec542021-05-26 15:33:11 -0400441 variant = SnapshotSharedSuffix
Jose Galmes7fdc3362021-05-26 21:16:52 -0700442 } else if p.static() {
Ivan Lozanod1dec542021-05-26 15:33:11 -0400443 variant = SnapshotStaticSuffix
Jose Galmes7fdc3362021-05-26 21:16:52 -0700444 } else {
445 variant = snapshotHeaderSuffix
446 }
447
Ivan Lozanod1dec542021-05-26 15:33:11 -0400448 p.SetSnapshotAndroidMkSuffix(ctx, variant)
Inseob Kim1b6fb872021-04-05 13:37:02 +0900449
Inseob Kimde5744a2020-12-02 13:14:28 +0900450 if p.header() {
451 return p.libraryDecorator.link(ctx, flags, deps, objs)
452 }
453
454 if p.sanitizerProperties.CfiEnabled {
455 p.properties = p.sanitizerProperties.Cfi
456 }
457
Ivan Lozanod1dec542021-05-26 15:33:11 -0400458 if !p.MatchesWithDevice(ctx.DeviceConfig()) {
Inseob Kimde5744a2020-12-02 13:14:28 +0900459 return nil
460 }
461
Inseob Kimdd0295d2021-04-12 21:09:59 +0900462 // Flags specified directly to this module.
Inseob Kimde5744a2020-12-02 13:14:28 +0900463 p.libraryDecorator.reexportDirs(android.PathsForModuleSrc(ctx, p.properties.Export_include_dirs)...)
464 p.libraryDecorator.reexportSystemDirs(android.PathsForModuleSrc(ctx, p.properties.Export_system_include_dirs)...)
465 p.libraryDecorator.reexportFlags(p.properties.Export_flags...)
466
Inseob Kimdd0295d2021-04-12 21:09:59 +0900467 // Flags reexported from dependencies. (e.g. vndk_prebuilt_shared)
468 p.libraryDecorator.reexportDirs(deps.ReexportedDirs...)
469 p.libraryDecorator.reexportSystemDirs(deps.ReexportedSystemDirs...)
470 p.libraryDecorator.reexportFlags(deps.ReexportedFlags...)
471 p.libraryDecorator.reexportDeps(deps.ReexportedDeps...)
472 p.libraryDecorator.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
473
Inseob Kimde5744a2020-12-02 13:14:28 +0900474 in := android.PathForModuleSrc(ctx, *p.properties.Src)
475 p.unstrippedOutputFile = in
476
477 if p.shared() {
478 libName := in.Base()
Inseob Kimde5744a2020-12-02 13:14:28 +0900479
480 // Optimize out relinking against shared libraries whose interface hasn't changed by
481 // depending on a table of contents file instead of the library itself.
482 tocFile := android.PathForModuleOut(ctx, libName+".toc")
483 p.tocFile = android.OptionalPathForPath(tocFile)
Ivan Lozano7b0781d2021-11-03 15:30:18 -0400484 TransformSharedObjectToToc(ctx, in, tocFile)
Inseob Kimde5744a2020-12-02 13:14:28 +0900485
486 ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{
Liz Kammeref6dfea2021-06-08 15:37:09 -0400487 SharedLibrary: in,
488 Target: ctx.Target(),
Inseob Kimde5744a2020-12-02 13:14:28 +0900489
490 TableOfContents: p.tocFile,
491 })
492 }
493
494 if p.static() {
495 depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(in).Build()
496 ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
497 StaticLibrary: in,
498
499 TransitiveStaticLibrariesForOrdering: depSet,
500 })
501 }
502
503 p.libraryDecorator.flagExporter.setProvider(ctx)
504
505 return in
506}
507
508func (p *snapshotLibraryDecorator) install(ctx ModuleContext, file android.Path) {
Inseob Kimbf1b63f2022-01-21 18:12:48 +0900509 if p.MatchesWithDevice(ctx.DeviceConfig()) && p.shared() {
Inseob Kimde5744a2020-12-02 13:14:28 +0900510 p.baseInstaller.install(ctx, file)
511 }
512}
513
514func (p *snapshotLibraryDecorator) nativeCoverage() bool {
515 return false
516}
517
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500518func (p *snapshotLibraryDecorator) isSanitizerEnabled(t SanitizerType) bool {
Inseob Kimde5744a2020-12-02 13:14:28 +0900519 switch t {
520 case cfi:
521 return p.sanitizerProperties.Cfi.Src != nil
522 default:
523 return false
524 }
525}
526
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500527func (p *snapshotLibraryDecorator) setSanitizerVariation(t SanitizerType, enabled bool) {
Inseob Kimde5744a2020-12-02 13:14:28 +0900528 if !enabled {
529 return
530 }
531 switch t {
532 case cfi:
533 p.sanitizerProperties.CfiEnabled = true
534 default:
535 return
536 }
537}
538
Ivan Lozanod1dec542021-05-26 15:33:11 -0400539func snapshotLibraryFactory(image SnapshotImage, moduleSuffix string) (*Module, *snapshotLibraryDecorator) {
Inseob Kimde5744a2020-12-02 13:14:28 +0900540 module, library := NewLibrary(android.DeviceSupported)
541
542 module.stl = nil
543 module.sanitize = nil
544 library.disableStripping()
545
546 prebuilt := &snapshotLibraryDecorator{
547 libraryDecorator: library,
548 }
549
550 prebuilt.baseLinker.Properties.No_libcrt = BoolPtr(true)
551 prebuilt.baseLinker.Properties.Nocrt = BoolPtr(true)
552
553 // Prevent default system libs (libc, libm, and libdl) from being linked
554 if prebuilt.baseLinker.Properties.System_shared_libs == nil {
555 prebuilt.baseLinker.Properties.System_shared_libs = []string{}
556 }
557
558 module.compiler = nil
559 module.linker = prebuilt
560 module.installer = prebuilt
561
Ivan Lozanod1dec542021-05-26 15:33:11 -0400562 prebuilt.Init(module, image, moduleSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900563 module.AddProperties(
564 &prebuilt.properties,
565 &prebuilt.sanitizerProperties,
566 )
567
568 return module, prebuilt
569}
570
571// vendor_snapshot_shared is a special prebuilt shared library which is auto-generated by
572// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_shared
573// overrides the vendor variant of the cc shared library with the same name, if BOARD_VNDK_VERSION
574// is set.
575func VendorSnapshotSharedFactory() android.Module {
Ivan Lozanod1dec542021-05-26 15:33:11 -0400576 module, prebuilt := snapshotLibraryFactory(VendorSnapshotImageSingleton, SnapshotSharedSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900577 prebuilt.libraryDecorator.BuildOnlyShared()
578 return module.Init()
579}
580
581// recovery_snapshot_shared is a special prebuilt shared library which is auto-generated by
582// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_shared
583// overrides the recovery variant of the cc shared library with the same name, if BOARD_VNDK_VERSION
584// is set.
585func RecoverySnapshotSharedFactory() android.Module {
Jose Galmesd7d99be2021-11-05 14:04:54 -0700586 module, prebuilt := snapshotLibraryFactory(RecoverySnapshotImageSingleton, SnapshotSharedSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900587 prebuilt.libraryDecorator.BuildOnlyShared()
588 return module.Init()
589}
590
591// vendor_snapshot_static is a special prebuilt static library which is auto-generated by
592// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_static
593// overrides the vendor variant of the cc static library with the same name, if BOARD_VNDK_VERSION
594// is set.
595func VendorSnapshotStaticFactory() android.Module {
Ivan Lozanod1dec542021-05-26 15:33:11 -0400596 module, prebuilt := snapshotLibraryFactory(VendorSnapshotImageSingleton, SnapshotStaticSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900597 prebuilt.libraryDecorator.BuildOnlyStatic()
598 return module.Init()
599}
600
601// recovery_snapshot_static is a special prebuilt static library which is auto-generated by
602// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_static
603// overrides the recovery variant of the cc static library with the same name, if BOARD_VNDK_VERSION
604// is set.
605func RecoverySnapshotStaticFactory() android.Module {
Jose Galmesd7d99be2021-11-05 14:04:54 -0700606 module, prebuilt := snapshotLibraryFactory(RecoverySnapshotImageSingleton, SnapshotStaticSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900607 prebuilt.libraryDecorator.BuildOnlyStatic()
608 return module.Init()
609}
610
611// vendor_snapshot_header is a special header library which is auto-generated by
612// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_header
613// overrides the vendor variant of the cc header library with the same name, if BOARD_VNDK_VERSION
614// is set.
615func VendorSnapshotHeaderFactory() android.Module {
Ivan Lozanod67a6b02021-05-20 13:01:32 -0400616 module, prebuilt := snapshotLibraryFactory(VendorSnapshotImageSingleton, snapshotHeaderSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900617 prebuilt.libraryDecorator.HeaderOnly()
618 return module.Init()
619}
620
621// recovery_snapshot_header is a special header library which is auto-generated by
622// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_header
623// overrides the recovery variant of the cc header library with the same name, if BOARD_VNDK_VERSION
624// is set.
625func RecoverySnapshotHeaderFactory() android.Module {
Jose Galmesd7d99be2021-11-05 14:04:54 -0700626 module, prebuilt := snapshotLibraryFactory(RecoverySnapshotImageSingleton, snapshotHeaderSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900627 prebuilt.libraryDecorator.HeaderOnly()
628 return module.Init()
629}
630
631var _ snapshotSanitizer = (*snapshotLibraryDecorator)(nil)
632
633//
634// Module definitions for snapshots of executable binaries.
635//
636// Modules (vendor|recovery)_snapshot_binary are defined here. They have their prebuilt executable
637// binaries (e.g. toybox, sh) as their src, which can be installed.
638//
639// These modules are auto-generated by development/vendor_snapshot/update.py.
640type snapshotBinaryProperties struct {
641 // Prebuilt file for each arch.
642 Src *string `android:"arch_variant"`
643}
644
645type snapshotBinaryDecorator struct {
Ivan Lozanod1dec542021-05-26 15:33:11 -0400646 BaseSnapshotDecorator
Inseob Kimde5744a2020-12-02 13:14:28 +0900647 *binaryDecorator
Colin Crossa8890802021-01-22 14:06:33 -0800648 properties snapshotBinaryProperties
Inseob Kimde5744a2020-12-02 13:14:28 +0900649}
650
Ivan Lozanod1dec542021-05-26 15:33:11 -0400651func (p *snapshotBinaryDecorator) MatchesWithDevice(config android.DeviceConfig) bool {
652 if config.DeviceArch() != p.Arch() {
Inseob Kimde5744a2020-12-02 13:14:28 +0900653 return false
654 }
655 if p.properties.Src == nil {
656 return false
657 }
658 return true
659}
660
661// cc modules' link functions are to link compiled objects into final binaries.
662// As snapshots are prebuilts, this just returns the prebuilt binary
663func (p *snapshotBinaryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
Ivan Lozanod1dec542021-05-26 15:33:11 -0400664 p.SetSnapshotAndroidMkSuffix(ctx, snapshotBinarySuffix)
Inseob Kim1b6fb872021-04-05 13:37:02 +0900665
Ivan Lozanod1dec542021-05-26 15:33:11 -0400666 if !p.MatchesWithDevice(ctx.DeviceConfig()) {
Inseob Kimde5744a2020-12-02 13:14:28 +0900667 return nil
668 }
669
670 in := android.PathForModuleSrc(ctx, *p.properties.Src)
671 p.unstrippedOutputFile = in
672 binName := in.Base()
673
Inseob Kimde5744a2020-12-02 13:14:28 +0900674 // use cpExecutable to make it executable
675 outputFile := android.PathForModuleOut(ctx, binName)
676 ctx.Build(pctx, android.BuildParams{
677 Rule: android.CpExecutable,
678 Description: "prebuilt",
679 Output: outputFile,
680 Input: in,
681 })
682
Inseob Kim4d945ee2022-02-24 10:29:18 +0900683 // binary snapshots need symlinking
684 p.setSymlinkList(ctx)
685
Inseob Kimde5744a2020-12-02 13:14:28 +0900686 return outputFile
687}
688
689func (p *snapshotBinaryDecorator) nativeCoverage() bool {
690 return false
691}
692
693// vendor_snapshot_binary is a special prebuilt executable binary which is auto-generated by
694// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_binary
695// overrides the vendor variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set.
696func VendorSnapshotBinaryFactory() android.Module {
Ivan Lozanod67a6b02021-05-20 13:01:32 -0400697 return snapshotBinaryFactory(VendorSnapshotImageSingleton, snapshotBinarySuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900698}
699
700// recovery_snapshot_binary is a special prebuilt executable binary which is auto-generated by
701// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_binary
702// overrides the recovery variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set.
703func RecoverySnapshotBinaryFactory() android.Module {
Jose Galmesd7d99be2021-11-05 14:04:54 -0700704 return snapshotBinaryFactory(RecoverySnapshotImageSingleton, snapshotBinarySuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900705}
706
Ivan Lozanod1dec542021-05-26 15:33:11 -0400707func snapshotBinaryFactory(image SnapshotImage, moduleSuffix string) android.Module {
Inseob Kimde5744a2020-12-02 13:14:28 +0900708 module, binary := NewBinary(android.DeviceSupported)
709 binary.baseLinker.Properties.No_libcrt = BoolPtr(true)
710 binary.baseLinker.Properties.Nocrt = BoolPtr(true)
711
712 // Prevent default system libs (libc, libm, and libdl) from being linked
713 if binary.baseLinker.Properties.System_shared_libs == nil {
714 binary.baseLinker.Properties.System_shared_libs = []string{}
715 }
716
717 prebuilt := &snapshotBinaryDecorator{
718 binaryDecorator: binary,
719 }
720
721 module.compiler = nil
722 module.sanitize = nil
723 module.stl = nil
724 module.linker = prebuilt
725
Ivan Lozanod1dec542021-05-26 15:33:11 -0400726 prebuilt.Init(module, image, moduleSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900727 module.AddProperties(&prebuilt.properties)
728 return module.Init()
729}
730
731//
732// Module definitions for snapshots of object files (*.o).
733//
734// Modules (vendor|recovery)_snapshot_object are defined here. They have their prebuilt object
735// files (*.o) as their src.
736//
737// These modules are auto-generated by development/vendor_snapshot/update.py.
738type vendorSnapshotObjectProperties struct {
739 // Prebuilt file for each arch.
740 Src *string `android:"arch_variant"`
741}
742
743type snapshotObjectLinker struct {
Ivan Lozanod1dec542021-05-26 15:33:11 -0400744 BaseSnapshotDecorator
Inseob Kimde5744a2020-12-02 13:14:28 +0900745 objectLinker
Colin Crossa8890802021-01-22 14:06:33 -0800746 properties vendorSnapshotObjectProperties
Inseob Kimde5744a2020-12-02 13:14:28 +0900747}
748
Ivan Lozanod1dec542021-05-26 15:33:11 -0400749func (p *snapshotObjectLinker) MatchesWithDevice(config android.DeviceConfig) bool {
750 if config.DeviceArch() != p.Arch() {
Inseob Kimde5744a2020-12-02 13:14:28 +0900751 return false
752 }
753 if p.properties.Src == nil {
754 return false
755 }
756 return true
757}
758
759// cc modules' link functions are to link compiled objects into final binaries.
760// As snapshots are prebuilts, this just returns the prebuilt binary
761func (p *snapshotObjectLinker) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
Ivan Lozanod1dec542021-05-26 15:33:11 -0400762 p.SetSnapshotAndroidMkSuffix(ctx, snapshotObjectSuffix)
Inseob Kim1b6fb872021-04-05 13:37:02 +0900763
Ivan Lozanod1dec542021-05-26 15:33:11 -0400764 if !p.MatchesWithDevice(ctx.DeviceConfig()) {
Inseob Kimde5744a2020-12-02 13:14:28 +0900765 return nil
766 }
767
Inseob Kimde5744a2020-12-02 13:14:28 +0900768 return android.PathForModuleSrc(ctx, *p.properties.Src)
769}
770
771func (p *snapshotObjectLinker) nativeCoverage() bool {
772 return false
773}
774
775// vendor_snapshot_object is a special prebuilt compiled object file which is auto-generated by
776// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_object
777// overrides the vendor variant of the cc object with the same name, if BOARD_VNDK_VERSION is set.
778func VendorSnapshotObjectFactory() android.Module {
Colin Cross7cabd422021-06-25 14:21:04 -0700779 module := newObject(android.DeviceSupported)
Inseob Kimde5744a2020-12-02 13:14:28 +0900780
781 prebuilt := &snapshotObjectLinker{
782 objectLinker: objectLinker{
783 baseLinker: NewBaseLinker(nil),
784 },
785 }
786 module.linker = prebuilt
787
Ivan Lozanod1dec542021-05-26 15:33:11 -0400788 prebuilt.Init(module, VendorSnapshotImageSingleton, snapshotObjectSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900789 module.AddProperties(&prebuilt.properties)
790 return module.Init()
791}
792
793// recovery_snapshot_object is a special prebuilt compiled object file which is auto-generated by
794// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_object
795// overrides the recovery variant of the cc object with the same name, if BOARD_VNDK_VERSION is set.
796func RecoverySnapshotObjectFactory() android.Module {
Colin Cross7cabd422021-06-25 14:21:04 -0700797 module := newObject(android.DeviceSupported)
Inseob Kimde5744a2020-12-02 13:14:28 +0900798
799 prebuilt := &snapshotObjectLinker{
800 objectLinker: objectLinker{
801 baseLinker: NewBaseLinker(nil),
802 },
803 }
804 module.linker = prebuilt
805
Jose Galmesd7d99be2021-11-05 14:04:54 -0700806 prebuilt.Init(module, RecoverySnapshotImageSingleton, snapshotObjectSuffix)
Inseob Kimde5744a2020-12-02 13:14:28 +0900807 module.AddProperties(&prebuilt.properties)
808 return module.Init()
809}
810
Ivan Lozanod1dec542021-05-26 15:33:11 -0400811type SnapshotInterface interface {
812 MatchesWithDevice(config android.DeviceConfig) bool
813 IsSnapshotPrebuilt() bool
814 Version() string
815 SnapshotAndroidMkSuffix() string
Inseob Kimde5744a2020-12-02 13:14:28 +0900816}
817
Ivan Lozanod1dec542021-05-26 15:33:11 -0400818var _ SnapshotInterface = (*vndkPrebuiltLibraryDecorator)(nil)
819var _ SnapshotInterface = (*snapshotLibraryDecorator)(nil)
820var _ SnapshotInterface = (*snapshotBinaryDecorator)(nil)
821var _ SnapshotInterface = (*snapshotObjectLinker)(nil)