blob: 13d77cc2daa0352a9ee7a401df3ebb3aa14e8aa0 [file] [log] [blame]
Inseob Kime498dd92020-08-04 09:24:04 +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 contains image variant related things, including image mutator functions, utility
17// functions to determine where a module is installed, etc.
18
19import (
Justin Yun6977e8a2020-10-29 18:24:11 +090020 "fmt"
21 "reflect"
Inseob Kime498dd92020-08-04 09:24:04 +090022 "strings"
23
24 "android/soong/android"
25)
26
27var _ android.ImageInterface = (*Module)(nil)
28
Inseob Kim74d25562020-08-04 00:41:38 +090029type imageVariantType string
30
31const (
Yifan Hong60e0cfb2020-10-21 15:17:56 -070032 coreImageVariant imageVariantType = "core"
33 vendorImageVariant imageVariantType = "vendor"
34 productImageVariant imageVariantType = "product"
35 ramdiskImageVariant imageVariantType = "ramdisk"
36 vendorRamdiskImageVariant imageVariantType = "vendor_ramdisk"
37 recoveryImageVariant imageVariantType = "recovery"
38 hostImageVariant imageVariantType = "host"
Inseob Kim74d25562020-08-04 00:41:38 +090039)
40
41func (c *Module) getImageVariantType() imageVariantType {
42 if c.Host() {
43 return hostImageVariant
44 } else if c.inVendor() {
45 return vendorImageVariant
Ivan Lozanof9e21722020-12-02 09:00:51 -050046 } else if c.InProduct() {
Inseob Kim74d25562020-08-04 00:41:38 +090047 return productImageVariant
48 } else if c.InRamdisk() {
49 return ramdiskImageVariant
Yifan Hong60e0cfb2020-10-21 15:17:56 -070050 } else if c.InVendorRamdisk() {
51 return vendorRamdiskImageVariant
Inseob Kim74d25562020-08-04 00:41:38 +090052 } else if c.InRecovery() {
53 return recoveryImageVariant
54 } else {
55 return coreImageVariant
56 }
57}
58
Inseob Kime498dd92020-08-04 09:24:04 +090059const (
60 // VendorVariationPrefix is the variant prefix used for /vendor code that compiles
61 // against the VNDK.
62 VendorVariationPrefix = "vendor."
63
64 // ProductVariationPrefix is the variant prefix used for /product code that compiles
65 // against the VNDK.
66 ProductVariationPrefix = "product."
67)
68
69func (ctx *moduleContext) ProductSpecific() bool {
Justin Yun63e9ec72020-10-29 16:49:43 +090070 //TODO(b/150902910): Replace HasNonSystemVariants() with HasProductVariant()
Inseob Kime498dd92020-08-04 09:24:04 +090071 return ctx.ModuleContext.ProductSpecific() ||
Ivan Lozanof9e21722020-12-02 09:00:51 -050072 (ctx.mod.HasNonSystemVariants() && ctx.mod.InProduct())
Inseob Kime498dd92020-08-04 09:24:04 +090073}
74
75func (ctx *moduleContext) SocSpecific() bool {
76 return ctx.ModuleContext.SocSpecific() ||
Justin Yun543f60b2020-10-18 10:54:31 +090077 (ctx.mod.HasVendorVariant() && ctx.mod.inVendor())
Inseob Kime498dd92020-08-04 09:24:04 +090078}
79
80func (ctx *moduleContextImpl) inProduct() bool {
Ivan Lozanof9e21722020-12-02 09:00:51 -050081 return ctx.mod.InProduct()
Inseob Kime498dd92020-08-04 09:24:04 +090082}
83
84func (ctx *moduleContextImpl) inVendor() bool {
85 return ctx.mod.inVendor()
86}
87
88func (ctx *moduleContextImpl) inRamdisk() bool {
89 return ctx.mod.InRamdisk()
90}
91
Yifan Hong60e0cfb2020-10-21 15:17:56 -070092func (ctx *moduleContextImpl) inVendorRamdisk() bool {
93 return ctx.mod.InVendorRamdisk()
94}
95
Inseob Kime498dd92020-08-04 09:24:04 +090096func (ctx *moduleContextImpl) inRecovery() bool {
97 return ctx.mod.InRecovery()
98}
99
Justin Yun63e9ec72020-10-29 16:49:43 +0900100// Returns true when this module is configured to have core and vendor variants.
Inseob Kime498dd92020-08-04 09:24:04 +0900101func (c *Module) HasVendorVariant() bool {
Justin Yun6977e8a2020-10-29 18:24:11 +0900102 // In case of a VNDK, 'vendor_available: false' still creates a vendor variant.
Inseob Kime498dd92020-08-04 09:24:04 +0900103 return c.IsVndk() || Bool(c.VendorProperties.Vendor_available)
104}
105
Justin Yun63e9ec72020-10-29 16:49:43 +0900106// Returns true when this module is configured to have core and product variants.
107func (c *Module) HasProductVariant() bool {
Justin Yun6977e8a2020-10-29 18:24:11 +0900108 if c.VendorProperties.Product_available == nil {
109 // Without 'product_available', product variant will not be created even for VNDKs.
110 return false
111 }
112 // However, 'product_available: false' in a VNDK still creates a product variant.
Justin Yun63e9ec72020-10-29 16:49:43 +0900113 return c.IsVndk() || Bool(c.VendorProperties.Product_available)
114}
115
116// Returns true when this module is configured to have core and either product or vendor variants.
117func (c *Module) HasNonSystemVariants() bool {
Justin Yun6977e8a2020-10-29 18:24:11 +0900118 return c.HasVendorVariant() || c.HasProductVariant()
Justin Yun63e9ec72020-10-29 16:49:43 +0900119}
120
Inseob Kime498dd92020-08-04 09:24:04 +0900121// Returns true if the module is "product" variant. Usually these modules are installed in /product
Ivan Lozanof9e21722020-12-02 09:00:51 -0500122func (c *Module) InProduct() bool {
Inseob Kime498dd92020-08-04 09:24:04 +0900123 return c.Properties.ImageVariationPrefix == ProductVariationPrefix
124}
125
126// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
127func (c *Module) inVendor() bool {
128 return c.Properties.ImageVariationPrefix == VendorVariationPrefix
129}
130
131func (c *Module) InRamdisk() bool {
132 return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
133}
134
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700135func (c *Module) InVendorRamdisk() bool {
136 return c.ModuleBase.InVendorRamdisk() || c.ModuleBase.InstallInVendorRamdisk()
137}
138
Inseob Kime498dd92020-08-04 09:24:04 +0900139func (c *Module) InRecovery() bool {
140 return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery()
141}
142
143func (c *Module) OnlyInRamdisk() bool {
144 return c.ModuleBase.InstallInRamdisk()
145}
146
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700147func (c *Module) OnlyInVendorRamdisk() bool {
148 return c.ModuleBase.InstallInVendorRamdisk()
149}
150
Inseob Kime498dd92020-08-04 09:24:04 +0900151func (c *Module) OnlyInRecovery() bool {
152 return c.ModuleBase.InstallInRecovery()
153}
154
Justin Yun6977e8a2020-10-29 18:24:11 +0900155func visitPropsAndCompareVendorAndProductProps(v reflect.Value) bool {
156 if v.Kind() != reflect.Struct {
157 return true
158 }
159 for i := 0; i < v.NumField(); i++ {
160 prop := v.Field(i)
161 if prop.Kind() == reflect.Struct && v.Type().Field(i).Name == "Target" {
162 vendor_prop := prop.FieldByName("Vendor")
163 product_prop := prop.FieldByName("Product")
164 if vendor_prop.Kind() != reflect.Struct && product_prop.Kind() != reflect.Struct {
165 // Neither Target.Vendor nor Target.Product is defined
166 continue
167 }
168 if vendor_prop.Kind() != reflect.Struct || product_prop.Kind() != reflect.Struct ||
169 !reflect.DeepEqual(vendor_prop.Interface(), product_prop.Interface()) {
170 // If only one of either Target.Vendor or Target.Product is
171 // defined or they have different values, it fails the build
172 // since VNDK must have the same properties for both vendor
173 // and product variants.
174 return false
175 }
176 } else if !visitPropsAndCompareVendorAndProductProps(prop) {
177 // Visit the substructures to find Target.Vendor and Target.Product
178 return false
179 }
180 }
181 return true
182}
183
184// In the case of VNDK, vendor and product variants must have the same properties.
185// VNDK installs only one file and shares it for both vendor and product modules on
186// runtime. We may not define different versions of a VNDK lib for each partition.
187// This function is used only for the VNDK modules that is available to both vendor
188// and product partitions.
189func (c *Module) compareVendorAndProductProps() bool {
190 if !c.IsVndk() && c.VendorProperties.Product_available != nil {
191 panic(fmt.Errorf("This is only for product available VNDK libs. %q is not a VNDK library or not product available", c.Name()))
192 }
193 for _, properties := range c.GetProperties() {
194 if !visitPropsAndCompareVendorAndProductProps(reflect.ValueOf(properties).Elem()) {
195 return false
196 }
197 }
198 return true
199}
200
Inseob Kime498dd92020-08-04 09:24:04 +0900201func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
202 // Validation check
203 vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
204 productSpecific := mctx.ProductSpecific()
205
Justin Yun63e9ec72020-10-29 16:49:43 +0900206 if m.VendorProperties.Vendor_available != nil {
207 if vendorSpecific {
208 mctx.PropertyErrorf("vendor_available",
209 "doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
210 }
Justin Yun63e9ec72020-10-29 16:49:43 +0900211 }
212
213 if m.VendorProperties.Product_available != nil {
214 if productSpecific {
215 mctx.PropertyErrorf("product_available",
216 "doesn't make sense at the same time as `product_specific: true`")
217 }
218 if vendorSpecific {
219 mctx.PropertyErrorf("product_available",
220 "cannot provide product variant from a vendor module. Please use `product_specific: true` with `vendor_available: true`")
221 }
Inseob Kime498dd92020-08-04 09:24:04 +0900222 }
223
224 if vndkdep := m.vndkdep; vndkdep != nil {
225 if vndkdep.isVndk() {
226 if vendorSpecific || productSpecific {
227 if !vndkdep.isVndkExt() {
228 mctx.PropertyErrorf("vndk",
229 "must set `extends: \"...\"` to vndk extension")
230 } else if m.VendorProperties.Vendor_available != nil {
231 mctx.PropertyErrorf("vendor_available",
232 "must not set at the same time as `vndk: {extends: \"...\"}`")
Justin Yun63e9ec72020-10-29 16:49:43 +0900233 } else if m.VendorProperties.Product_available != nil {
234 mctx.PropertyErrorf("product_available",
235 "must not set at the same time as `vndk: {extends: \"...\"}`")
Inseob Kime498dd92020-08-04 09:24:04 +0900236 }
237 } else {
238 if vndkdep.isVndkExt() {
239 mctx.PropertyErrorf("vndk",
240 "must set `vendor: true` or `product_specific: true` to set `extends: %q`",
241 m.getVndkExtendsModuleName())
242 }
243 if m.VendorProperties.Vendor_available == nil {
244 mctx.PropertyErrorf("vndk",
245 "vendor_available must be set to either true or false when `vndk: {enabled: true}`")
246 }
Justin Yun6977e8a2020-10-29 18:24:11 +0900247 if m.VendorProperties.Product_available != nil {
Justin Yunfd9e8042020-12-23 18:23:14 +0900248 // If a VNDK module creates both product and vendor variants, they
249 // must have the same properties since they share a single VNDK
250 // library on runtime.
Justin Yun6977e8a2020-10-29 18:24:11 +0900251 if !m.compareVendorAndProductProps() {
252 mctx.ModuleErrorf("product properties must have the same values with the vendor properties for VNDK modules")
253 }
254 }
Inseob Kime498dd92020-08-04 09:24:04 +0900255 }
256 } else {
257 if vndkdep.isVndkSp() {
258 mctx.PropertyErrorf("vndk",
259 "must set `enabled: true` to set `support_system_process: true`")
260 }
261 if vndkdep.isVndkExt() {
262 mctx.PropertyErrorf("vndk",
263 "must set `enabled: true` to set `extends: %q`",
264 m.getVndkExtendsModuleName())
265 }
266 }
267 }
268
269 var coreVariantNeeded bool = false
270 var ramdiskVariantNeeded bool = false
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700271 var vendorRamdiskVariantNeeded bool = false
Inseob Kime498dd92020-08-04 09:24:04 +0900272 var recoveryVariantNeeded bool = false
273
274 var vendorVariants []string
275 var productVariants []string
276
277 platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion()
278 boardVndkVersion := mctx.DeviceConfig().VndkVersion()
279 productVndkVersion := mctx.DeviceConfig().ProductVndkVersion()
280 if boardVndkVersion == "current" {
281 boardVndkVersion = platformVndkVersion
282 }
283 if productVndkVersion == "current" {
284 productVndkVersion = platformVndkVersion
285 }
286
287 if boardVndkVersion == "" {
288 // If the device isn't compiling against the VNDK, we always
289 // use the core mode.
290 coreVariantNeeded = true
291 } else if _, ok := m.linker.(*llndkStubDecorator); ok {
292 // LL-NDK stubs only exist in the vendor and product variants,
293 // since the real libraries will be used in the core variant.
294 vendorVariants = append(vendorVariants,
295 platformVndkVersion,
296 boardVndkVersion,
297 )
298 productVariants = append(productVariants,
299 platformVndkVersion,
300 productVndkVersion,
301 )
302 } else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
303 // ... and LL-NDK headers as well
304 vendorVariants = append(vendorVariants,
305 platformVndkVersion,
306 boardVndkVersion,
307 )
308 productVariants = append(productVariants,
309 platformVndkVersion,
310 productVndkVersion,
311 )
312 } else if m.isSnapshotPrebuilt() {
313 // Make vendor variants only for the versions in BOARD_VNDK_VERSION and
314 // PRODUCT_EXTRA_VNDK_VERSIONS.
315 if snapshot, ok := m.linker.(interface {
316 version() string
317 }); ok {
318 vendorVariants = append(vendorVariants, snapshot.version())
319 } else {
320 mctx.ModuleErrorf("version is unknown for snapshot prebuilt")
321 }
Ivan Lozanof9e21722020-12-02 09:00:51 -0500322 } else if m.HasNonSystemVariants() && !m.IsVndkExt() {
Justin Yun63e9ec72020-10-29 16:49:43 +0900323 // This will be available to /system unless it is product_specific
324 // which will be handled later.
Inseob Kime498dd92020-08-04 09:24:04 +0900325 coreVariantNeeded = true
326
327 // We assume that modules under proprietary paths are compatible for
328 // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or
329 // PLATFORM_VNDK_VERSION.
Justin Yun63e9ec72020-10-29 16:49:43 +0900330 if m.HasVendorVariant() {
331 if isVendorProprietaryModule(mctx) {
332 vendorVariants = append(vendorVariants, boardVndkVersion)
333 } else {
334 vendorVariants = append(vendorVariants, platformVndkVersion)
335 }
Inseob Kime498dd92020-08-04 09:24:04 +0900336 }
337
Justin Yun6977e8a2020-10-29 18:24:11 +0900338 // product_available modules are available to /product.
339 if m.HasProductVariant() {
340 productVariants = append(productVariants, platformVndkVersion)
341 // VNDK is always PLATFORM_VNDK_VERSION
342 if !m.IsVndk() {
343 productVariants = append(productVariants, productVndkVersion)
344 }
Inseob Kime498dd92020-08-04 09:24:04 +0900345 }
346 } else if vendorSpecific && String(m.Properties.Sdk_version) == "" {
347 // This will be available in /vendor (or /odm) only
348
349 // kernel_headers is a special module type whose exported headers
350 // are coming from DeviceKernelHeaders() which is always vendor
351 // dependent. They'll always have both vendor variants.
352 // For other modules, we assume that modules under proprietary
353 // paths are compatible for BOARD_VNDK_VERSION. The other modules
354 // are regarded as AOSP, which is PLATFORM_VNDK_VERSION.
355 if _, ok := m.linker.(*kernelHeadersDecorator); ok {
356 vendorVariants = append(vendorVariants,
357 platformVndkVersion,
358 boardVndkVersion,
359 )
Bill Peckham945441c2020-08-31 16:07:58 -0700360 } else if isVendorProprietaryModule(mctx) {
Inseob Kime498dd92020-08-04 09:24:04 +0900361 vendorVariants = append(vendorVariants, boardVndkVersion)
362 } else {
363 vendorVariants = append(vendorVariants, platformVndkVersion)
364 }
Colin Cross127bb8b2020-12-16 16:46:01 -0800365 } else if lib := moduleLibraryInterface(m); lib != nil && lib.hasLLNDKStubs() {
366 // This is an LLNDK library. The implementation of the library will be on /system,
367 // and vendor and product variants will be created with LLNDK stubs.
368 coreVariantNeeded = true
369 vendorVariants = append(vendorVariants,
370 platformVndkVersion,
371 boardVndkVersion,
372 )
373 productVariants = append(productVariants,
374 platformVndkVersion,
375 productVndkVersion,
376 )
Inseob Kime498dd92020-08-04 09:24:04 +0900377 } else {
378 // This is either in /system (or similar: /data), or is a
379 // modules built with the NDK. Modules built with the NDK
380 // will be restricted using the existing link type checks.
381 coreVariantNeeded = true
382 }
383
384 if boardVndkVersion != "" && productVndkVersion != "" {
385 if coreVariantNeeded && productSpecific && String(m.Properties.Sdk_version) == "" {
386 // The module has "product_specific: true" that does not create core variant.
387 coreVariantNeeded = false
388 productVariants = append(productVariants, productVndkVersion)
389 }
390 } else {
391 // Unless PRODUCT_PRODUCT_VNDK_VERSION is set, product partition has no
392 // restriction to use system libs.
393 // No product variants defined in this case.
394 productVariants = []string{}
395 }
396
397 if Bool(m.Properties.Ramdisk_available) {
398 ramdiskVariantNeeded = true
399 }
400
401 if m.ModuleBase.InstallInRamdisk() {
402 ramdiskVariantNeeded = true
403 coreVariantNeeded = false
404 }
405
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700406 if Bool(m.Properties.Vendor_ramdisk_available) {
407 vendorRamdiskVariantNeeded = true
408 }
409
410 if m.ModuleBase.InstallInVendorRamdisk() {
411 vendorRamdiskVariantNeeded = true
412 coreVariantNeeded = false
413 }
414
Inseob Kime498dd92020-08-04 09:24:04 +0900415 if Bool(m.Properties.Recovery_available) {
416 recoveryVariantNeeded = true
417 }
418
419 if m.ModuleBase.InstallInRecovery() {
420 recoveryVariantNeeded = true
421 coreVariantNeeded = false
422 }
423
424 for _, variant := range android.FirstUniqueStrings(vendorVariants) {
425 m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, VendorVariationPrefix+variant)
426 }
427
428 for _, variant := range android.FirstUniqueStrings(productVariants) {
429 m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, ProductVariationPrefix+variant)
430 }
431
432 m.Properties.RamdiskVariantNeeded = ramdiskVariantNeeded
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700433 m.Properties.VendorRamdiskVariantNeeded = vendorRamdiskVariantNeeded
Inseob Kime498dd92020-08-04 09:24:04 +0900434 m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded
435 m.Properties.CoreVariantNeeded = coreVariantNeeded
436}
437
438func (c *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
439 return c.Properties.CoreVariantNeeded
440}
441
442func (c *Module) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
443 return c.Properties.RamdiskVariantNeeded
444}
445
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700446func (c *Module) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
447 return c.Properties.VendorRamdiskVariantNeeded
448}
449
Inseob Kime498dd92020-08-04 09:24:04 +0900450func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
451 return c.Properties.RecoveryVariantNeeded
452}
453
454func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
455 return c.Properties.ExtraVariants
456}
457
Justin Yun63e9ec72020-10-29 16:49:43 +0900458func squashVendorSrcs(m *Module) {
459 if lib, ok := m.compiler.(*libraryDecorator); ok {
460 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
461 lib.baseCompiler.Properties.Target.Vendor.Srcs...)
462
463 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
464 lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
465
466 lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
467 lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...)
468 }
469}
470
471func squashProductSrcs(m *Module) {
472 if lib, ok := m.compiler.(*libraryDecorator); ok {
473 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
474 lib.baseCompiler.Properties.Target.Product.Srcs...)
475
476 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
477 lib.baseCompiler.Properties.Target.Product.Exclude_srcs...)
478
479 lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
480 lib.baseCompiler.Properties.Target.Product.Exclude_generated_sources...)
481 }
482}
483
484func squashRecoverySrcs(m *Module) {
485 if lib, ok := m.compiler.(*libraryDecorator); ok {
486 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
487 lib.baseCompiler.Properties.Target.Recovery.Srcs...)
488
489 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
490 lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
491
492 lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
493 lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...)
494 }
495}
496
497func squashVendorRamdiskSrcs(m *Module) {
498 if lib, ok := m.compiler.(*libraryDecorator); ok {
499 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs...)
500 }
501}
502
Inseob Kime498dd92020-08-04 09:24:04 +0900503func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
504 m := module.(*Module)
Yifan Hong6da33c22020-10-27 15:01:21 -0700505 if variant == android.RamdiskVariation {
Inseob Kime498dd92020-08-04 09:24:04 +0900506 m.MakeAsPlatform()
Yifan Hong6da33c22020-10-27 15:01:21 -0700507 } else if variant == android.VendorRamdiskVariation {
508 m.MakeAsPlatform()
509 squashVendorRamdiskSrcs(m)
Inseob Kime498dd92020-08-04 09:24:04 +0900510 } else if variant == android.RecoveryVariation {
511 m.MakeAsPlatform()
512 squashRecoverySrcs(m)
513 } else if strings.HasPrefix(variant, VendorVariationPrefix) {
514 m.Properties.ImageVariationPrefix = VendorVariationPrefix
515 m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
516 squashVendorSrcs(m)
517
518 // Makefile shouldn't know vendor modules other than BOARD_VNDK_VERSION.
519 // Hide other vendor variants to avoid collision.
520 vndkVersion := ctx.DeviceConfig().VndkVersion()
521 if vndkVersion != "current" && vndkVersion != "" && vndkVersion != m.Properties.VndkVersion {
522 m.Properties.HideFromMake = true
Colin Crossa9c8c9f2020-12-16 10:20:23 -0800523 m.HideFromMake()
Inseob Kime498dd92020-08-04 09:24:04 +0900524 }
525 } else if strings.HasPrefix(variant, ProductVariationPrefix) {
526 m.Properties.ImageVariationPrefix = ProductVariationPrefix
527 m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
Justin Yun6977e8a2020-10-29 18:24:11 +0900528 squashProductSrcs(m)
Inseob Kime498dd92020-08-04 09:24:04 +0900529 }
530}