Define odm_available property to install a vendor variant to odm

'vendor_available: true' creates a vendor variant from a system
module. The vendor variant of the module is installed to /vendor.
However, we may want to install the vendor variant to /odm, instead.

'device_specific: true' does not work for this purpose because
'vendor_available: true' is allowed only for the system or product
modules to create a vendor variant. But 'device_specific: true'
itself creates a vendor variant that may not work with
'vendor_available: true'.

To install the vendor variant to /odm, we define a new property
'odm_available'. 'odm_available' is exactly the same as the
'vendor_available' except the install path of the vendor variant.
By defining 'odm_available: true', the vendor variant of the module
will be installed to /odm or /vendor/odm instead of /vendor.

Bug: 176147321
Bug: 176079978
Test: check if a module with 'odm_available: true' is installed to
      /vendor/odm
Change-Id: I2d16bd2c515796597b2fbd1eb66f7c2736434697
This commit is contained in:
Justin Yun
2021-01-08 18:00:19 +09:00
parent f17b07fc52
commit ebcf0c5e15
6 changed files with 57 additions and 18 deletions

View File

@@ -68,11 +68,7 @@ func (mod *Module) OnlyInVendorRamdisk() bool {
// Returns true when this module is configured to have core and vendor variants.
func (mod *Module) HasVendorVariant() bool {
return mod.IsVndk() || Bool(mod.VendorProperties.Vendor_available)
}
func (c *Module) VendorAvailable() bool {
return Bool(c.VendorProperties.Vendor_available)
return Bool(mod.VendorProperties.Vendor_available) || Bool(mod.VendorProperties.Odm_available)
}
func (c *Module) InProduct() bool {
@@ -114,10 +110,15 @@ func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
coreVariantNeeded := true
var vendorVariants []string
if Bool(mod.VendorProperties.Vendor_available) {
if mod.HasVendorVariant() {
prop := "vendor_available"
if Bool(mod.VendorProperties.Odm_available) {
prop = "odm_available"
}
if vendorSpecific {
mctx.PropertyErrorf("vendor_available",
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
mctx.PropertyErrorf(prop,
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific: true`")
}
if lib, ok := mod.compiler.(libraryInterface); ok {
@@ -128,9 +129,8 @@ func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
// We can't check shared() here because image mutator is called before the library mutator, so we need to
// check buildShared()
if lib.buildShared() {
mctx.PropertyErrorf("vendor_available",
"vendor_available can only be set for rust_ffi_static modules.")
} else if Bool(mod.VendorProperties.Vendor_available) == true {
mctx.PropertyErrorf(prop, "can only be set for rust_ffi_static modules.")
} else {
vendorVariants = append(vendorVariants, platformVndkVersion)
}
}