Remove cc.moduleContext override of android.ModuleContext.*Specific
Overriding android.ModuleContext's implementations of *Specific() methods in cc.moduleContext and then passing that back to android.PathForModuleInstall to affect the install path causes problems if android.ModuleBase.GenerateBuildActions also tries to call android.PathForModuleInstall directly with the android.ModuleContext as it gets a different result. Add InstallIn* methods to the android.Module interface, implement default versions in android.ModuleBase, and override them in cc.Module and rust.Module. Use them in android.PathsForModuleInstall to allow the module to customize the behavior directly. Test: TestInstallPartition Change-Id: I7840e07eae34ac4f4d3490b021143d5f33a83626
This commit is contained in:
@@ -77,6 +77,8 @@ type Module interface {
|
||||
InstallInDebugRamdisk() bool
|
||||
InstallInRecovery() bool
|
||||
InstallInRoot() bool
|
||||
InstallInOdm() bool
|
||||
InstallInProduct() bool
|
||||
InstallInVendor() bool
|
||||
InstallForceOS() (*OsType, *ArchType)
|
||||
PartitionTag(DeviceConfig) string
|
||||
@@ -1399,6 +1401,14 @@ func (m *ModuleBase) InstallInRecovery() bool {
|
||||
return Bool(m.commonProperties.Recovery)
|
||||
}
|
||||
|
||||
func (m *ModuleBase) InstallInOdm() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *ModuleBase) InstallInProduct() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *ModuleBase) InstallInVendor() bool {
|
||||
return Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Soc_specific) || Bool(m.commonProperties.Proprietary)
|
||||
}
|
||||
|
@@ -181,6 +181,8 @@ type ModuleContext interface {
|
||||
InstallInDebugRamdisk() bool
|
||||
InstallInRecovery() bool
|
||||
InstallInRoot() bool
|
||||
InstallInOdm() bool
|
||||
InstallInProduct() bool
|
||||
InstallInVendor() bool
|
||||
InstallForceOS() (*OsType, *ArchType)
|
||||
|
||||
@@ -438,6 +440,14 @@ func (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
|
||||
return m.module.InstallForceOS()
|
||||
}
|
||||
|
||||
func (m *moduleContext) InstallInOdm() bool {
|
||||
return m.module.InstallInOdm()
|
||||
}
|
||||
|
||||
func (m *moduleContext) InstallInProduct() bool {
|
||||
return m.module.InstallInProduct()
|
||||
}
|
||||
|
||||
func (m *moduleContext) InstallInVendor() bool {
|
||||
return m.module.InstallInVendor()
|
||||
}
|
||||
|
@@ -111,6 +111,9 @@ type ModuleInstallPathContext interface {
|
||||
InstallInDebugRamdisk() bool
|
||||
InstallInRecovery() bool
|
||||
InstallInRoot() bool
|
||||
InstallInOdm() bool
|
||||
InstallInProduct() bool
|
||||
InstallInVendor() bool
|
||||
InstallForceOS() (*OsType, *ArchType)
|
||||
}
|
||||
|
||||
@@ -152,6 +155,18 @@ func (ctx *baseModuleContextToModuleInstallPathContext) InstallInRoot() bool {
|
||||
return ctx.Module().InstallInRoot()
|
||||
}
|
||||
|
||||
func (ctx *baseModuleContextToModuleInstallPathContext) InstallInOdm() bool {
|
||||
return ctx.Module().InstallInOdm()
|
||||
}
|
||||
|
||||
func (ctx *baseModuleContextToModuleInstallPathContext) InstallInProduct() bool {
|
||||
return ctx.Module().InstallInProduct()
|
||||
}
|
||||
|
||||
func (ctx *baseModuleContextToModuleInstallPathContext) InstallInVendor() bool {
|
||||
return ctx.Module().InstallInVendor()
|
||||
}
|
||||
|
||||
func (ctx *baseModuleContextToModuleInstallPathContext) InstallForceOS() (*OsType, *ArchType) {
|
||||
return ctx.Module().InstallForceOS()
|
||||
}
|
||||
@@ -1866,11 +1881,11 @@ func modulePartition(ctx ModuleInstallPathContext, device bool) string {
|
||||
// the layout of recovery partion is the same as that of system partition
|
||||
partition = "recovery/root/system"
|
||||
}
|
||||
} else if ctx.SocSpecific() {
|
||||
} else if ctx.SocSpecific() || ctx.InstallInVendor() {
|
||||
partition = ctx.DeviceConfig().VendorPath()
|
||||
} else if ctx.DeviceSpecific() {
|
||||
} else if ctx.DeviceSpecific() || ctx.InstallInOdm() {
|
||||
partition = ctx.DeviceConfig().OdmPath()
|
||||
} else if ctx.ProductSpecific() {
|
||||
} else if ctx.ProductSpecific() || ctx.InstallInProduct() {
|
||||
partition = ctx.DeviceConfig().ProductPath()
|
||||
} else if ctx.SystemExtSpecific() {
|
||||
partition = ctx.DeviceConfig().SystemExtPath()
|
||||
@@ -2066,6 +2081,9 @@ type testModuleInstallPathContext struct {
|
||||
inDebugRamdisk bool
|
||||
inRecovery bool
|
||||
inRoot bool
|
||||
inOdm bool
|
||||
inProduct bool
|
||||
inVendor bool
|
||||
forceOS *OsType
|
||||
forceArch *ArchType
|
||||
}
|
||||
@@ -2108,6 +2126,18 @@ func (m testModuleInstallPathContext) InstallInRoot() bool {
|
||||
return m.inRoot
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInOdm() bool {
|
||||
return m.inOdm
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInProduct() bool {
|
||||
return m.inProduct
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInVendor() bool {
|
||||
return m.inVendor
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallForceOS() (*OsType, *ArchType) {
|
||||
return m.forceOS, m.forceArch
|
||||
}
|
||||
|
@@ -194,13 +194,13 @@ func checkInstallPartition(t *testing.T, ctx *android.TestContext, name, variant
|
||||
}
|
||||
}
|
||||
socSpecific := func(m *Module) bool {
|
||||
return m.SocSpecific() || m.socSpecificModuleContext()
|
||||
return m.SocSpecific() || m.InstallInVendor()
|
||||
}
|
||||
deviceSpecific := func(m *Module) bool {
|
||||
return m.DeviceSpecific() || m.deviceSpecificModuleContext()
|
||||
return m.DeviceSpecific() || m.InstallInOdm()
|
||||
}
|
||||
productSpecific := func(m *Module) bool {
|
||||
return m.ProductSpecific() || m.productSpecificModuleContext()
|
||||
return m.ProductSpecific() || m.InstallInProduct()
|
||||
}
|
||||
systemExtSpecific := func(m *Module) bool {
|
||||
return m.SystemExtSpecific()
|
||||
|
18
cc/image.go
18
cc/image.go
@@ -51,18 +51,6 @@ const (
|
||||
ProductVariationPrefix = "product."
|
||||
)
|
||||
|
||||
func (ctx *moduleContext) ProductSpecific() bool {
|
||||
return ctx.ModuleContext.ProductSpecific() || ctx.mod.productSpecificModuleContext()
|
||||
}
|
||||
|
||||
func (ctx *moduleContext) SocSpecific() bool {
|
||||
return ctx.ModuleContext.SocSpecific() || ctx.mod.socSpecificModuleContext()
|
||||
}
|
||||
|
||||
func (ctx *moduleContext) DeviceSpecific() bool {
|
||||
return ctx.ModuleContext.DeviceSpecific() || ctx.mod.deviceSpecificModuleContext()
|
||||
}
|
||||
|
||||
func (ctx *moduleContextImpl) inProduct() bool {
|
||||
return ctx.mod.InProduct()
|
||||
}
|
||||
@@ -83,20 +71,20 @@ func (ctx *moduleContextImpl) inRecovery() bool {
|
||||
return ctx.mod.InRecovery()
|
||||
}
|
||||
|
||||
func (c *Module) productSpecificModuleContext() bool {
|
||||
func (c *Module) InstallInProduct() bool {
|
||||
// Additionally check if this module is inProduct() that means it is a "product" variant of a
|
||||
// module. As well as product specific modules, product variants must be installed to /product.
|
||||
return c.InProduct()
|
||||
}
|
||||
|
||||
func (c *Module) socSpecificModuleContext() bool {
|
||||
func (c *Module) InstallInVendor() bool {
|
||||
// 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
|
||||
// unless they have "odm_available: true".
|
||||
return c.HasVendorVariant() && c.InVendor() && !c.VendorVariantToOdm()
|
||||
}
|
||||
|
||||
func (c *Module) deviceSpecificModuleContext() bool {
|
||||
func (c *Module) InstallInOdm() bool {
|
||||
// Some vendor variants want to be installed to /odm by setting "odm_available: true".
|
||||
return c.InVendor() && c.VendorVariantToOdm()
|
||||
}
|
||||
|
@@ -117,20 +117,16 @@ func (mod *Module) IsSnapshotPrebuilt() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ctx *moduleContext) SocSpecific() bool {
|
||||
func (mod *Module) InstallInVendor() bool {
|
||||
// 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
|
||||
// unless they have "odm_available: true".
|
||||
return ctx.ModuleContext.SocSpecific() || (ctx.RustModule().InVendor() && !ctx.RustModule().VendorVariantToOdm())
|
||||
return mod.InVendor() && !mod.VendorVariantToOdm()
|
||||
}
|
||||
|
||||
func (ctx *moduleContext) DeviceSpecific() bool {
|
||||
func (mod *Module) InstallInOdm() bool {
|
||||
// Some vendor variants want to be installed to /odm by setting "odm_available: true".
|
||||
return ctx.ModuleContext.DeviceSpecific() || (ctx.RustModule().InVendor() && ctx.RustModule().VendorVariantToOdm())
|
||||
}
|
||||
|
||||
func (ctx *moduleContext) SystemExtSpecific() bool {
|
||||
return ctx.ModuleContext.SystemExtSpecific()
|
||||
return mod.InVendor() && mod.VendorVariantToOdm()
|
||||
}
|
||||
|
||||
// Returns true when this module creates a vendor variant and wants to install the vendor variant
|
||||
|
Reference in New Issue
Block a user