blob: 623b9eea2af76c94c60ebeb9dbab1f2e33462d5d [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 {
70 return ctx.ModuleContext.ProductSpecific() ||
Justin Yun8a2600c2020-12-07 12:44:03 +090071 (ctx.mod.HasProductVariant() && ctx.mod.InProduct())
Inseob Kime498dd92020-08-04 09:24:04 +090072}
73
74func (ctx *moduleContext) SocSpecific() bool {
75 return ctx.ModuleContext.SocSpecific() ||
Justin Yun543f60b2020-10-18 10:54:31 +090076 (ctx.mod.HasVendorVariant() && ctx.mod.inVendor())
Inseob Kime498dd92020-08-04 09:24:04 +090077}
78
79func (ctx *moduleContextImpl) inProduct() bool {
Ivan Lozanof9e21722020-12-02 09:00:51 -050080 return ctx.mod.InProduct()
Inseob Kime498dd92020-08-04 09:24:04 +090081}
82
83func (ctx *moduleContextImpl) inVendor() bool {
84 return ctx.mod.inVendor()
85}
86
87func (ctx *moduleContextImpl) inRamdisk() bool {
88 return ctx.mod.InRamdisk()
89}
90
Yifan Hong60e0cfb2020-10-21 15:17:56 -070091func (ctx *moduleContextImpl) inVendorRamdisk() bool {
92 return ctx.mod.InVendorRamdisk()
93}
94
Inseob Kime498dd92020-08-04 09:24:04 +090095func (ctx *moduleContextImpl) inRecovery() bool {
96 return ctx.mod.InRecovery()
97}
98
Justin Yun63e9ec72020-10-29 16:49:43 +090099// Returns true when this module is configured to have core and vendor variants.
Inseob Kime498dd92020-08-04 09:24:04 +0900100func (c *Module) HasVendorVariant() bool {
Justin Yun6977e8a2020-10-29 18:24:11 +0900101 // In case of a VNDK, 'vendor_available: false' still creates a vendor variant.
Inseob Kime498dd92020-08-04 09:24:04 +0900102 return c.IsVndk() || Bool(c.VendorProperties.Vendor_available)
103}
104
Justin Yun63e9ec72020-10-29 16:49:43 +0900105// Returns true when this module is configured to have core and product variants.
106func (c *Module) HasProductVariant() bool {
Justin Yun6977e8a2020-10-29 18:24:11 +0900107 if c.VendorProperties.Product_available == nil {
108 // Without 'product_available', product variant will not be created even for VNDKs.
109 return false
110 }
111 // However, 'product_available: false' in a VNDK still creates a product variant.
Justin Yun63e9ec72020-10-29 16:49:43 +0900112 return c.IsVndk() || Bool(c.VendorProperties.Product_available)
113}
114
115// Returns true when this module is configured to have core and either product or vendor variants.
116func (c *Module) HasNonSystemVariants() bool {
Justin Yun6977e8a2020-10-29 18:24:11 +0900117 return c.HasVendorVariant() || c.HasProductVariant()
Justin Yun63e9ec72020-10-29 16:49:43 +0900118}
119
Inseob Kime498dd92020-08-04 09:24:04 +0900120// Returns true if the module is "product" variant. Usually these modules are installed in /product
Ivan Lozanof9e21722020-12-02 09:00:51 -0500121func (c *Module) InProduct() bool {
Inseob Kime498dd92020-08-04 09:24:04 +0900122 return c.Properties.ImageVariationPrefix == ProductVariationPrefix
123}
124
125// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
126func (c *Module) inVendor() bool {
127 return c.Properties.ImageVariationPrefix == VendorVariationPrefix
128}
129
130func (c *Module) InRamdisk() bool {
131 return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
132}
133
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700134func (c *Module) InVendorRamdisk() bool {
135 return c.ModuleBase.InVendorRamdisk() || c.ModuleBase.InstallInVendorRamdisk()
136}
137
Inseob Kime498dd92020-08-04 09:24:04 +0900138func (c *Module) InRecovery() bool {
139 return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery()
140}
141
142func (c *Module) OnlyInRamdisk() bool {
143 return c.ModuleBase.InstallInRamdisk()
144}
145
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700146func (c *Module) OnlyInVendorRamdisk() bool {
147 return c.ModuleBase.InstallInVendorRamdisk()
148}
149
Inseob Kime498dd92020-08-04 09:24:04 +0900150func (c *Module) OnlyInRecovery() bool {
151 return c.ModuleBase.InstallInRecovery()
152}
153
Justin Yun6977e8a2020-10-29 18:24:11 +0900154func visitPropsAndCompareVendorAndProductProps(v reflect.Value) bool {
155 if v.Kind() != reflect.Struct {
156 return true
157 }
158 for i := 0; i < v.NumField(); i++ {
159 prop := v.Field(i)
160 if prop.Kind() == reflect.Struct && v.Type().Field(i).Name == "Target" {
161 vendor_prop := prop.FieldByName("Vendor")
162 product_prop := prop.FieldByName("Product")
163 if vendor_prop.Kind() != reflect.Struct && product_prop.Kind() != reflect.Struct {
164 // Neither Target.Vendor nor Target.Product is defined
165 continue
166 }
167 if vendor_prop.Kind() != reflect.Struct || product_prop.Kind() != reflect.Struct ||
168 !reflect.DeepEqual(vendor_prop.Interface(), product_prop.Interface()) {
169 // If only one of either Target.Vendor or Target.Product is
170 // defined or they have different values, it fails the build
171 // since VNDK must have the same properties for both vendor
172 // and product variants.
173 return false
174 }
175 } else if !visitPropsAndCompareVendorAndProductProps(prop) {
176 // Visit the substructures to find Target.Vendor and Target.Product
177 return false
178 }
179 }
180 return true
181}
182
183// In the case of VNDK, vendor and product variants must have the same properties.
184// VNDK installs only one file and shares it for both vendor and product modules on
185// runtime. We may not define different versions of a VNDK lib for each partition.
186// This function is used only for the VNDK modules that is available to both vendor
187// and product partitions.
188func (c *Module) compareVendorAndProductProps() bool {
189 if !c.IsVndk() && c.VendorProperties.Product_available != nil {
190 panic(fmt.Errorf("This is only for product available VNDK libs. %q is not a VNDK library or not product available", c.Name()))
191 }
192 for _, properties := range c.GetProperties() {
193 if !visitPropsAndCompareVendorAndProductProps(reflect.ValueOf(properties).Elem()) {
194 return false
195 }
196 }
197 return true
198}
199
Inseob Kime498dd92020-08-04 09:24:04 +0900200func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
201 // Validation check
202 vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
203 productSpecific := mctx.ProductSpecific()
204
Justin Yun63e9ec72020-10-29 16:49:43 +0900205 if m.VendorProperties.Vendor_available != nil {
206 if vendorSpecific {
207 mctx.PropertyErrorf("vendor_available",
208 "doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
209 }
Justin Yun63e9ec72020-10-29 16:49:43 +0900210 }
211
212 if m.VendorProperties.Product_available != nil {
213 if productSpecific {
214 mctx.PropertyErrorf("product_available",
215 "doesn't make sense at the same time as `product_specific: true`")
216 }
217 if vendorSpecific {
218 mctx.PropertyErrorf("product_available",
219 "cannot provide product variant from a vendor module. Please use `product_specific: true` with `vendor_available: true`")
220 }
Inseob Kime498dd92020-08-04 09:24:04 +0900221 }
222
223 if vndkdep := m.vndkdep; vndkdep != nil {
224 if vndkdep.isVndk() {
225 if vendorSpecific || productSpecific {
226 if !vndkdep.isVndkExt() {
227 mctx.PropertyErrorf("vndk",
228 "must set `extends: \"...\"` to vndk extension")
229 } else if m.VendorProperties.Vendor_available != nil {
230 mctx.PropertyErrorf("vendor_available",
231 "must not set at the same time as `vndk: {extends: \"...\"}`")
Justin Yun63e9ec72020-10-29 16:49:43 +0900232 } else if m.VendorProperties.Product_available != nil {
233 mctx.PropertyErrorf("product_available",
234 "must not set at the same time as `vndk: {extends: \"...\"}`")
Inseob Kime498dd92020-08-04 09:24:04 +0900235 }
236 } else {
237 if vndkdep.isVndkExt() {
238 mctx.PropertyErrorf("vndk",
239 "must set `vendor: true` or `product_specific: true` to set `extends: %q`",
240 m.getVndkExtendsModuleName())
241 }
242 if m.VendorProperties.Vendor_available == nil {
243 mctx.PropertyErrorf("vndk",
244 "vendor_available must be set to either true or false when `vndk: {enabled: true}`")
245 }
Justin Yun6977e8a2020-10-29 18:24:11 +0900246 if m.VendorProperties.Product_available != nil {
Justin Yunfd9e8042020-12-23 18:23:14 +0900247 // If a VNDK module creates both product and vendor variants, they
248 // must have the same properties since they share a single VNDK
249 // library on runtime.
Justin Yun6977e8a2020-10-29 18:24:11 +0900250 if !m.compareVendorAndProductProps() {
251 mctx.ModuleErrorf("product properties must have the same values with the vendor properties for VNDK modules")
252 }
253 }
Inseob Kime498dd92020-08-04 09:24:04 +0900254 }
255 } else {
256 if vndkdep.isVndkSp() {
257 mctx.PropertyErrorf("vndk",
258 "must set `enabled: true` to set `support_system_process: true`")
259 }
260 if vndkdep.isVndkExt() {
261 mctx.PropertyErrorf("vndk",
262 "must set `enabled: true` to set `extends: %q`",
263 m.getVndkExtendsModuleName())
264 }
265 }
266 }
267
268 var coreVariantNeeded bool = false
269 var ramdiskVariantNeeded bool = false
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700270 var vendorRamdiskVariantNeeded bool = false
Inseob Kime498dd92020-08-04 09:24:04 +0900271 var recoveryVariantNeeded bool = false
272
273 var vendorVariants []string
274 var productVariants []string
275
276 platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion()
277 boardVndkVersion := mctx.DeviceConfig().VndkVersion()
278 productVndkVersion := mctx.DeviceConfig().ProductVndkVersion()
279 if boardVndkVersion == "current" {
280 boardVndkVersion = platformVndkVersion
281 }
282 if productVndkVersion == "current" {
283 productVndkVersion = platformVndkVersion
284 }
285
286 if boardVndkVersion == "" {
287 // If the device isn't compiling against the VNDK, we always
288 // use the core mode.
289 coreVariantNeeded = true
290 } else if _, ok := m.linker.(*llndkStubDecorator); ok {
291 // LL-NDK stubs only exist in the vendor and product variants,
292 // since the real libraries will be used in the core variant.
293 vendorVariants = append(vendorVariants,
294 platformVndkVersion,
295 boardVndkVersion,
296 )
297 productVariants = append(productVariants,
298 platformVndkVersion,
299 productVndkVersion,
300 )
301 } else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
302 // ... and LL-NDK headers as well
303 vendorVariants = append(vendorVariants,
304 platformVndkVersion,
305 boardVndkVersion,
306 )
307 productVariants = append(productVariants,
308 platformVndkVersion,
309 productVndkVersion,
310 )
311 } else if m.isSnapshotPrebuilt() {
312 // Make vendor variants only for the versions in BOARD_VNDK_VERSION and
313 // PRODUCT_EXTRA_VNDK_VERSIONS.
314 if snapshot, ok := m.linker.(interface {
315 version() string
316 }); ok {
317 vendorVariants = append(vendorVariants, snapshot.version())
318 } else {
319 mctx.ModuleErrorf("version is unknown for snapshot prebuilt")
320 }
Ivan Lozanof9e21722020-12-02 09:00:51 -0500321 } else if m.HasNonSystemVariants() && !m.IsVndkExt() {
Justin Yun63e9ec72020-10-29 16:49:43 +0900322 // This will be available to /system unless it is product_specific
323 // which will be handled later.
Inseob Kime498dd92020-08-04 09:24:04 +0900324 coreVariantNeeded = true
325
326 // We assume that modules under proprietary paths are compatible for
327 // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or
328 // PLATFORM_VNDK_VERSION.
Justin Yun63e9ec72020-10-29 16:49:43 +0900329 if m.HasVendorVariant() {
330 if isVendorProprietaryModule(mctx) {
331 vendorVariants = append(vendorVariants, boardVndkVersion)
332 } else {
333 vendorVariants = append(vendorVariants, platformVndkVersion)
334 }
Inseob Kime498dd92020-08-04 09:24:04 +0900335 }
336
Justin Yun6977e8a2020-10-29 18:24:11 +0900337 // product_available modules are available to /product.
338 if m.HasProductVariant() {
339 productVariants = append(productVariants, platformVndkVersion)
340 // VNDK is always PLATFORM_VNDK_VERSION
341 if !m.IsVndk() {
342 productVariants = append(productVariants, productVndkVersion)
343 }
Inseob Kime498dd92020-08-04 09:24:04 +0900344 }
345 } else if vendorSpecific && String(m.Properties.Sdk_version) == "" {
346 // This will be available in /vendor (or /odm) only
347
348 // kernel_headers is a special module type whose exported headers
349 // are coming from DeviceKernelHeaders() which is always vendor
350 // dependent. They'll always have both vendor variants.
351 // For other modules, we assume that modules under proprietary
352 // paths are compatible for BOARD_VNDK_VERSION. The other modules
353 // are regarded as AOSP, which is PLATFORM_VNDK_VERSION.
354 if _, ok := m.linker.(*kernelHeadersDecorator); ok {
355 vendorVariants = append(vendorVariants,
356 platformVndkVersion,
357 boardVndkVersion,
358 )
Bill Peckham945441c2020-08-31 16:07:58 -0700359 } else if isVendorProprietaryModule(mctx) {
Inseob Kime498dd92020-08-04 09:24:04 +0900360 vendorVariants = append(vendorVariants, boardVndkVersion)
361 } else {
362 vendorVariants = append(vendorVariants, platformVndkVersion)
363 }
Colin Cross127bb8b2020-12-16 16:46:01 -0800364 } else if lib := moduleLibraryInterface(m); lib != nil && lib.hasLLNDKStubs() {
365 // This is an LLNDK library. The implementation of the library will be on /system,
366 // and vendor and product variants will be created with LLNDK stubs.
367 coreVariantNeeded = true
368 vendorVariants = append(vendorVariants,
369 platformVndkVersion,
370 boardVndkVersion,
371 )
372 productVariants = append(productVariants,
373 platformVndkVersion,
374 productVndkVersion,
375 )
Inseob Kime498dd92020-08-04 09:24:04 +0900376 } else {
377 // This is either in /system (or similar: /data), or is a
378 // modules built with the NDK. Modules built with the NDK
379 // will be restricted using the existing link type checks.
380 coreVariantNeeded = true
381 }
382
383 if boardVndkVersion != "" && productVndkVersion != "" {
384 if coreVariantNeeded && productSpecific && String(m.Properties.Sdk_version) == "" {
385 // The module has "product_specific: true" that does not create core variant.
386 coreVariantNeeded = false
387 productVariants = append(productVariants, productVndkVersion)
388 }
389 } else {
390 // Unless PRODUCT_PRODUCT_VNDK_VERSION is set, product partition has no
391 // restriction to use system libs.
392 // No product variants defined in this case.
393 productVariants = []string{}
394 }
395
396 if Bool(m.Properties.Ramdisk_available) {
397 ramdiskVariantNeeded = true
398 }
399
400 if m.ModuleBase.InstallInRamdisk() {
401 ramdiskVariantNeeded = true
402 coreVariantNeeded = false
403 }
404
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700405 if Bool(m.Properties.Vendor_ramdisk_available) {
406 vendorRamdiskVariantNeeded = true
407 }
408
409 if m.ModuleBase.InstallInVendorRamdisk() {
410 vendorRamdiskVariantNeeded = true
411 coreVariantNeeded = false
412 }
413
Inseob Kime498dd92020-08-04 09:24:04 +0900414 if Bool(m.Properties.Recovery_available) {
415 recoveryVariantNeeded = true
416 }
417
418 if m.ModuleBase.InstallInRecovery() {
419 recoveryVariantNeeded = true
420 coreVariantNeeded = false
421 }
422
423 for _, variant := range android.FirstUniqueStrings(vendorVariants) {
424 m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, VendorVariationPrefix+variant)
425 }
426
427 for _, variant := range android.FirstUniqueStrings(productVariants) {
428 m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, ProductVariationPrefix+variant)
429 }
430
431 m.Properties.RamdiskVariantNeeded = ramdiskVariantNeeded
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700432 m.Properties.VendorRamdiskVariantNeeded = vendorRamdiskVariantNeeded
Inseob Kime498dd92020-08-04 09:24:04 +0900433 m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded
434 m.Properties.CoreVariantNeeded = coreVariantNeeded
435}
436
437func (c *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
438 return c.Properties.CoreVariantNeeded
439}
440
441func (c *Module) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
442 return c.Properties.RamdiskVariantNeeded
443}
444
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700445func (c *Module) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
446 return c.Properties.VendorRamdiskVariantNeeded
447}
448
Inseob Kime498dd92020-08-04 09:24:04 +0900449func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
450 return c.Properties.RecoveryVariantNeeded
451}
452
453func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
454 return c.Properties.ExtraVariants
455}
456
Justin Yun63e9ec72020-10-29 16:49:43 +0900457func squashVendorSrcs(m *Module) {
458 if lib, ok := m.compiler.(*libraryDecorator); ok {
459 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
460 lib.baseCompiler.Properties.Target.Vendor.Srcs...)
461
462 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
463 lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
464
465 lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
466 lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...)
467 }
468}
469
470func squashProductSrcs(m *Module) {
471 if lib, ok := m.compiler.(*libraryDecorator); ok {
472 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
473 lib.baseCompiler.Properties.Target.Product.Srcs...)
474
475 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
476 lib.baseCompiler.Properties.Target.Product.Exclude_srcs...)
477
478 lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
479 lib.baseCompiler.Properties.Target.Product.Exclude_generated_sources...)
480 }
481}
482
483func squashRecoverySrcs(m *Module) {
484 if lib, ok := m.compiler.(*libraryDecorator); ok {
485 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
486 lib.baseCompiler.Properties.Target.Recovery.Srcs...)
487
488 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
489 lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
490
491 lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
492 lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...)
493 }
494}
495
496func squashVendorRamdiskSrcs(m *Module) {
497 if lib, ok := m.compiler.(*libraryDecorator); ok {
498 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs...)
499 }
500}
501
Inseob Kime498dd92020-08-04 09:24:04 +0900502func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
503 m := module.(*Module)
Yifan Hong6da33c22020-10-27 15:01:21 -0700504 if variant == android.RamdiskVariation {
Inseob Kime498dd92020-08-04 09:24:04 +0900505 m.MakeAsPlatform()
Yifan Hong6da33c22020-10-27 15:01:21 -0700506 } else if variant == android.VendorRamdiskVariation {
507 m.MakeAsPlatform()
508 squashVendorRamdiskSrcs(m)
Inseob Kime498dd92020-08-04 09:24:04 +0900509 } else if variant == android.RecoveryVariation {
510 m.MakeAsPlatform()
511 squashRecoverySrcs(m)
512 } else if strings.HasPrefix(variant, VendorVariationPrefix) {
513 m.Properties.ImageVariationPrefix = VendorVariationPrefix
514 m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
515 squashVendorSrcs(m)
516
517 // Makefile shouldn't know vendor modules other than BOARD_VNDK_VERSION.
518 // Hide other vendor variants to avoid collision.
519 vndkVersion := ctx.DeviceConfig().VndkVersion()
520 if vndkVersion != "current" && vndkVersion != "" && vndkVersion != m.Properties.VndkVersion {
521 m.Properties.HideFromMake = true
Colin Crossa9c8c9f2020-12-16 10:20:23 -0800522 m.HideFromMake()
Inseob Kime498dd92020-08-04 09:24:04 +0900523 }
524 } else if strings.HasPrefix(variant, ProductVariationPrefix) {
525 m.Properties.ImageVariationPrefix = ProductVariationPrefix
526 m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
Justin Yun6977e8a2020-10-29 18:24:11 +0900527 squashProductSrcs(m)
Inseob Kime498dd92020-08-04 09:24:04 +0900528 }
529}