Add vendor-ramdisk image to Soong.

Add vendor_ramdisk_available and vendor_ramdisk attribute to
various rules. When a vendor_ramdisk variant of a module is
generated, it is installed to $OUT/vendor-ramdisk.

It is similar to a ramdisk image.
Test: m nothing -j

Change-Id: Ib2d16459f3094dbe21c3bdb7c016cb4b2bf62765
This commit is contained in:
Yifan Hong
2020-10-21 15:17:56 -07:00
parent 627ce86770
commit 60e0cfb5cb
19 changed files with 188 additions and 48 deletions

View File

@@ -27,12 +27,13 @@ var _ android.ImageInterface = (*Module)(nil)
type imageVariantType string
const (
coreImageVariant imageVariantType = "core"
vendorImageVariant imageVariantType = "vendor"
productImageVariant imageVariantType = "product"
ramdiskImageVariant imageVariantType = "ramdisk"
recoveryImageVariant imageVariantType = "recovery"
hostImageVariant imageVariantType = "host"
coreImageVariant imageVariantType = "core"
vendorImageVariant imageVariantType = "vendor"
productImageVariant imageVariantType = "product"
ramdiskImageVariant imageVariantType = "ramdisk"
vendorRamdiskImageVariant imageVariantType = "vendor_ramdisk"
recoveryImageVariant imageVariantType = "recovery"
hostImageVariant imageVariantType = "host"
)
func (c *Module) getImageVariantType() imageVariantType {
@@ -44,6 +45,8 @@ func (c *Module) getImageVariantType() imageVariantType {
return productImageVariant
} else if c.InRamdisk() {
return ramdiskImageVariant
} else if c.InVendorRamdisk() {
return vendorRamdiskImageVariant
} else if c.InRecovery() {
return recoveryImageVariant
} else {
@@ -83,6 +86,10 @@ func (ctx *moduleContextImpl) inRamdisk() bool {
return ctx.mod.InRamdisk()
}
func (ctx *moduleContextImpl) inVendorRamdisk() bool {
return ctx.mod.InVendorRamdisk()
}
func (ctx *moduleContextImpl) inRecovery() bool {
return ctx.mod.InRecovery()
}
@@ -107,6 +114,10 @@ func (c *Module) InRamdisk() bool {
return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
}
func (c *Module) InVendorRamdisk() bool {
return c.ModuleBase.InVendorRamdisk() || c.ModuleBase.InstallInVendorRamdisk()
}
func (c *Module) InRecovery() bool {
return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery()
}
@@ -115,6 +126,10 @@ func (c *Module) OnlyInRamdisk() bool {
return c.ModuleBase.InstallInRamdisk()
}
func (c *Module) OnlyInVendorRamdisk() bool {
return c.ModuleBase.InstallInVendorRamdisk()
}
func (c *Module) OnlyInRecovery() bool {
return c.ModuleBase.InstallInRecovery()
}
@@ -165,6 +180,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
var coreVariantNeeded bool = false
var ramdiskVariantNeeded bool = false
var vendorRamdiskVariantNeeded bool = false
var recoveryVariantNeeded bool = false
var vendorVariants []string
@@ -283,6 +299,15 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
coreVariantNeeded = false
}
if Bool(m.Properties.Vendor_ramdisk_available) {
vendorRamdiskVariantNeeded = true
}
if m.ModuleBase.InstallInVendorRamdisk() {
vendorRamdiskVariantNeeded = true
coreVariantNeeded = false
}
if Bool(m.Properties.Recovery_available) {
recoveryVariantNeeded = true
}
@@ -301,6 +326,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
}
m.Properties.RamdiskVariantNeeded = ramdiskVariantNeeded
m.Properties.VendorRamdiskVariantNeeded = vendorRamdiskVariantNeeded
m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded
m.Properties.CoreVariantNeeded = coreVariantNeeded
}
@@ -313,6 +339,10 @@ func (c *Module) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.RamdiskVariantNeeded
}
func (c *Module) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.VendorRamdiskVariantNeeded
}
func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.RecoveryVariantNeeded
}
@@ -323,7 +353,7 @@ func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module)
if variant == android.RamdiskVariation {
if variant == android.RamdiskVariation || variant == android.VendorRamdiskVariation {
m.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()