Merge "Define odm_available property to install a vendor variant to odm" am: 65490b8cf3
am: cae1637ce5
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1542687 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Iaa87e97cf8d08ccc5dffd6d57ca8eaa03d267968
This commit is contained in:
11
cc/cc.go
11
cc/cc.go
@@ -390,6 +390,17 @@ type VendorProperties struct {
|
|||||||
// Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
|
// Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
|
||||||
Vendor_available *bool
|
Vendor_available *bool
|
||||||
|
|
||||||
|
// This is the same as the "vendor_available" except that the install path
|
||||||
|
// of the vendor variant is /odm or /vendor/odm.
|
||||||
|
// By replacing "vendor_available: true" with "odm_available: true", the
|
||||||
|
// module will install its vendor variant to the /odm partition or /vendor/odm.
|
||||||
|
// As the modules with "odm_available: true" still create the vendor variants,
|
||||||
|
// they can link to the other vendor modules as the vendor_available modules do.
|
||||||
|
// Also, the vendor modules can link to odm_available modules.
|
||||||
|
//
|
||||||
|
// It may not be used for VNDK modules.
|
||||||
|
Odm_available *bool
|
||||||
|
|
||||||
// whether this module should be allowed to be directly depended by other
|
// whether this module should be allowed to be directly depended by other
|
||||||
// modules with `product_specific: true` or `product_available: true`.
|
// modules with `product_specific: true` or `product_available: true`.
|
||||||
// If set to true, an additional product variant will be built separately
|
// If set to true, an additional product variant will be built separately
|
||||||
|
@@ -25,6 +25,7 @@ func init() {
|
|||||||
|
|
||||||
type GenruleExtraProperties struct {
|
type GenruleExtraProperties struct {
|
||||||
Vendor_available *bool
|
Vendor_available *bool
|
||||||
|
Odm_available *bool
|
||||||
Product_available *bool
|
Product_available *bool
|
||||||
Ramdisk_available *bool
|
Ramdisk_available *bool
|
||||||
Vendor_ramdisk_available *bool
|
Vendor_ramdisk_available *bool
|
||||||
@@ -63,7 +64,7 @@ func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return Bool(g.Vendor_available) || Bool(g.Product_available) || !(ctx.SocSpecific() || ctx.DeviceSpecific())
|
return !(ctx.SocSpecific() || ctx.DeviceSpecific())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
|
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
|
||||||
@@ -92,7 +93,7 @@ func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleCont
|
|||||||
}
|
}
|
||||||
|
|
||||||
var variants []string
|
var variants []string
|
||||||
if Bool(g.Vendor_available) || ctx.SocSpecific() || ctx.DeviceSpecific() {
|
if Bool(g.Vendor_available) || Bool(g.Odm_available) || ctx.SocSpecific() || ctx.DeviceSpecific() {
|
||||||
vndkVersion := ctx.DeviceConfig().VndkVersion()
|
vndkVersion := ctx.DeviceConfig().VndkVersion()
|
||||||
// If vndkVersion is current, we can always use PlatformVndkVersion.
|
// If vndkVersion is current, we can always use PlatformVndkVersion.
|
||||||
// If not, we assume modules under proprietary paths are compatible for
|
// If not, we assume modules under proprietary paths are compatible for
|
||||||
|
29
cc/image.go
29
cc/image.go
@@ -56,8 +56,14 @@ func (ctx *moduleContext) ProductSpecific() bool {
|
|||||||
|
|
||||||
func (ctx *moduleContext) SocSpecific() bool {
|
func (ctx *moduleContext) SocSpecific() bool {
|
||||||
// Additionally check if this module is inVendor() that means it is a "vendor" variant of a
|
// Additionally check if this module is inVendor() that means it is a "vendor" variant of a
|
||||||
// module. As well as SoC specific modules, vendor variants must be installed to /vendor.
|
// module. As well as SoC specific modules, vendor variants must be installed to /vendor
|
||||||
return ctx.ModuleContext.SocSpecific() || ctx.mod.InVendor()
|
// unless they have "odm_available: true".
|
||||||
|
return ctx.ModuleContext.SocSpecific() || (ctx.mod.InVendor() && !ctx.mod.VendorVariantToOdm())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *moduleContext) DeviceSpecific() bool {
|
||||||
|
// Some vendor variants want to be installed to /odm by setting "odm_available: true".
|
||||||
|
return ctx.ModuleContext.DeviceSpecific() || (ctx.mod.InVendor() && ctx.mod.VendorVariantToOdm())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) inProduct() bool {
|
func (ctx *moduleContextImpl) inProduct() bool {
|
||||||
@@ -82,7 +88,13 @@ func (ctx *moduleContextImpl) inRecovery() bool {
|
|||||||
|
|
||||||
// Returns true when this module is configured to have core and vendor variants.
|
// Returns true when this module is configured to have core and vendor variants.
|
||||||
func (c *Module) HasVendorVariant() bool {
|
func (c *Module) HasVendorVariant() bool {
|
||||||
return Bool(c.VendorProperties.Vendor_available)
|
return Bool(c.VendorProperties.Vendor_available) || Bool(c.VendorProperties.Odm_available)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when this module creates a vendor variant and wants to install the vendor variant
|
||||||
|
// to the odm partition.
|
||||||
|
func (c *Module) VendorVariantToOdm() bool {
|
||||||
|
return Bool(c.VendorProperties.Odm_available)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true when this module is configured to have core and product variants.
|
// Returns true when this module is configured to have core and product variants.
|
||||||
@@ -185,6 +197,17 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
|
|||||||
mctx.PropertyErrorf("vendor_available",
|
mctx.PropertyErrorf("vendor_available",
|
||||||
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific: true`")
|
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific: true`")
|
||||||
}
|
}
|
||||||
|
if Bool(m.VendorProperties.Odm_available) {
|
||||||
|
mctx.PropertyErrorf("vendor_available",
|
||||||
|
"doesn't make sense at the same time as `odm_available: true`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if Bool(m.VendorProperties.Odm_available) {
|
||||||
|
if vendorSpecific {
|
||||||
|
mctx.PropertyErrorf("odm_available",
|
||||||
|
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific: true`")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if Bool(m.VendorProperties.Product_available) {
|
if Bool(m.VendorProperties.Product_available) {
|
||||||
|
@@ -130,6 +130,10 @@ func (mt *librarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext,
|
|||||||
pbm.AddProperty("vendor_available", true)
|
pbm.AddProperty("vendor_available", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if proptools.Bool(ccModule.VendorProperties.Odm_available) {
|
||||||
|
pbm.AddProperty("odm_available", true)
|
||||||
|
}
|
||||||
|
|
||||||
if proptools.Bool(ccModule.VendorProperties.Product_available) {
|
if proptools.Bool(ccModule.VendorProperties.Product_available) {
|
||||||
pbm.AddProperty("product_available", true)
|
pbm.AddProperty("product_available", true)
|
||||||
}
|
}
|
||||||
|
@@ -68,11 +68,7 @@ func (mod *Module) OnlyInVendorRamdisk() bool {
|
|||||||
|
|
||||||
// Returns true when this module is configured to have core and vendor variants.
|
// Returns true when this module is configured to have core and vendor variants.
|
||||||
func (mod *Module) HasVendorVariant() bool {
|
func (mod *Module) HasVendorVariant() bool {
|
||||||
return mod.IsVndk() || Bool(mod.VendorProperties.Vendor_available)
|
return Bool(mod.VendorProperties.Vendor_available) || Bool(mod.VendorProperties.Odm_available)
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Module) VendorAvailable() bool {
|
|
||||||
return Bool(c.VendorProperties.Vendor_available)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) InProduct() bool {
|
func (c *Module) InProduct() bool {
|
||||||
@@ -114,9 +110,14 @@ func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
|
|||||||
coreVariantNeeded := true
|
coreVariantNeeded := true
|
||||||
var vendorVariants []string
|
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 {
|
if vendorSpecific {
|
||||||
mctx.PropertyErrorf("vendor_available",
|
mctx.PropertyErrorf(prop,
|
||||||
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific: true`")
|
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific: true`")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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
|
// We can't check shared() here because image mutator is called before the library mutator, so we need to
|
||||||
// check buildShared()
|
// check buildShared()
|
||||||
if lib.buildShared() {
|
if lib.buildShared() {
|
||||||
mctx.PropertyErrorf("vendor_available",
|
mctx.PropertyErrorf(prop, "can only be set for rust_ffi_static modules.")
|
||||||
"vendor_available can only be set for rust_ffi_static modules.")
|
} else {
|
||||||
} else if Bool(mod.VendorProperties.Vendor_available) == true {
|
|
||||||
vendorVariants = append(vendorVariants, platformVndkVersion)
|
vendorVariants = append(vendorVariants, platformVndkVersion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ func TestVendorLinkage(t *testing.T) {
|
|||||||
|
|
||||||
// Test that shared libraries cannot be made vendor available until proper support is added.
|
// Test that shared libraries cannot be made vendor available until proper support is added.
|
||||||
func TestForbiddenVendorLinkage(t *testing.T) {
|
func TestForbiddenVendorLinkage(t *testing.T) {
|
||||||
testRustError(t, "vendor_available can only be set for rust_ffi_static modules", `
|
testRustError(t, "can only be set for rust_ffi_static modules", `
|
||||||
rust_ffi_shared {
|
rust_ffi_shared {
|
||||||
name: "libfoo_vendor",
|
name: "libfoo_vendor",
|
||||||
crate_name: "foo",
|
crate_name: "foo",
|
||||||
|
Reference in New Issue
Block a user