Merge "Remove cc.moduleContext override of android.ModuleContext.*Specific" into main

This commit is contained in:
Colin Cross
2023-12-19 23:39:54 +00:00
committed by Gerrit Code Review
6 changed files with 63 additions and 29 deletions

View File

@@ -77,6 +77,8 @@ type Module interface {
InstallInDebugRamdisk() bool InstallInDebugRamdisk() bool
InstallInRecovery() bool InstallInRecovery() bool
InstallInRoot() bool InstallInRoot() bool
InstallInOdm() bool
InstallInProduct() bool
InstallInVendor() bool InstallInVendor() bool
InstallForceOS() (*OsType, *ArchType) InstallForceOS() (*OsType, *ArchType)
PartitionTag(DeviceConfig) string PartitionTag(DeviceConfig) string
@@ -1399,6 +1401,14 @@ func (m *ModuleBase) InstallInRecovery() bool {
return Bool(m.commonProperties.Recovery) return Bool(m.commonProperties.Recovery)
} }
func (m *ModuleBase) InstallInOdm() bool {
return false
}
func (m *ModuleBase) InstallInProduct() bool {
return false
}
func (m *ModuleBase) InstallInVendor() bool { func (m *ModuleBase) InstallInVendor() bool {
return Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Soc_specific) || Bool(m.commonProperties.Proprietary) return Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Soc_specific) || Bool(m.commonProperties.Proprietary)
} }

View File

@@ -181,6 +181,8 @@ type ModuleContext interface {
InstallInDebugRamdisk() bool InstallInDebugRamdisk() bool
InstallInRecovery() bool InstallInRecovery() bool
InstallInRoot() bool InstallInRoot() bool
InstallInOdm() bool
InstallInProduct() bool
InstallInVendor() bool InstallInVendor() bool
InstallForceOS() (*OsType, *ArchType) InstallForceOS() (*OsType, *ArchType)
@@ -438,6 +440,14 @@ func (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
return m.module.InstallForceOS() 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 { func (m *moduleContext) InstallInVendor() bool {
return m.module.InstallInVendor() return m.module.InstallInVendor()
} }

View File

@@ -111,6 +111,9 @@ type ModuleInstallPathContext interface {
InstallInDebugRamdisk() bool InstallInDebugRamdisk() bool
InstallInRecovery() bool InstallInRecovery() bool
InstallInRoot() bool InstallInRoot() bool
InstallInOdm() bool
InstallInProduct() bool
InstallInVendor() bool
InstallForceOS() (*OsType, *ArchType) InstallForceOS() (*OsType, *ArchType)
} }
@@ -152,6 +155,18 @@ func (ctx *baseModuleContextToModuleInstallPathContext) InstallInRoot() bool {
return ctx.Module().InstallInRoot() 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) { func (ctx *baseModuleContextToModuleInstallPathContext) InstallForceOS() (*OsType, *ArchType) {
return ctx.Module().InstallForceOS() 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 // the layout of recovery partion is the same as that of system partition
partition = "recovery/root/system" partition = "recovery/root/system"
} }
} else if ctx.SocSpecific() { } else if ctx.SocSpecific() || ctx.InstallInVendor() {
partition = ctx.DeviceConfig().VendorPath() partition = ctx.DeviceConfig().VendorPath()
} else if ctx.DeviceSpecific() { } else if ctx.DeviceSpecific() || ctx.InstallInOdm() {
partition = ctx.DeviceConfig().OdmPath() partition = ctx.DeviceConfig().OdmPath()
} else if ctx.ProductSpecific() { } else if ctx.ProductSpecific() || ctx.InstallInProduct() {
partition = ctx.DeviceConfig().ProductPath() partition = ctx.DeviceConfig().ProductPath()
} else if ctx.SystemExtSpecific() { } else if ctx.SystemExtSpecific() {
partition = ctx.DeviceConfig().SystemExtPath() partition = ctx.DeviceConfig().SystemExtPath()
@@ -2066,6 +2081,9 @@ type testModuleInstallPathContext struct {
inDebugRamdisk bool inDebugRamdisk bool
inRecovery bool inRecovery bool
inRoot bool inRoot bool
inOdm bool
inProduct bool
inVendor bool
forceOS *OsType forceOS *OsType
forceArch *ArchType forceArch *ArchType
} }
@@ -2108,6 +2126,18 @@ func (m testModuleInstallPathContext) InstallInRoot() bool {
return m.inRoot 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) { func (m testModuleInstallPathContext) InstallForceOS() (*OsType, *ArchType) {
return m.forceOS, m.forceArch return m.forceOS, m.forceArch
} }

View File

@@ -194,13 +194,13 @@ func checkInstallPartition(t *testing.T, ctx *android.TestContext, name, variant
} }
} }
socSpecific := func(m *Module) bool { socSpecific := func(m *Module) bool {
return m.SocSpecific() || m.socSpecificModuleContext() return m.SocSpecific() || m.InstallInVendor()
} }
deviceSpecific := func(m *Module) bool { deviceSpecific := func(m *Module) bool {
return m.DeviceSpecific() || m.deviceSpecificModuleContext() return m.DeviceSpecific() || m.InstallInOdm()
} }
productSpecific := func(m *Module) bool { productSpecific := func(m *Module) bool {
return m.ProductSpecific() || m.productSpecificModuleContext() return m.ProductSpecific() || m.InstallInProduct()
} }
systemExtSpecific := func(m *Module) bool { systemExtSpecific := func(m *Module) bool {
return m.SystemExtSpecific() return m.SystemExtSpecific()

View File

@@ -51,18 +51,6 @@ const (
ProductVariationPrefix = "product." 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 { func (ctx *moduleContextImpl) inProduct() bool {
return ctx.mod.InProduct() return ctx.mod.InProduct()
} }
@@ -83,20 +71,20 @@ func (ctx *moduleContextImpl) inRecovery() bool {
return ctx.mod.InRecovery() 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 // 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. // module. As well as product specific modules, product variants must be installed to /product.
return c.InProduct() 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 // 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
// unless they have "odm_available: true". // unless they have "odm_available: true".
return c.HasVendorVariant() && c.InVendor() && !c.VendorVariantToOdm() 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". // Some vendor variants want to be installed to /odm by setting "odm_available: true".
return c.InVendor() && c.VendorVariantToOdm() return c.InVendor() && c.VendorVariantToOdm()
} }

View File

@@ -117,20 +117,16 @@ func (mod *Module) IsSnapshotPrebuilt() bool {
return false 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 // 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
// unless they have "odm_available: true". // 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". // Some vendor variants want to be installed to /odm by setting "odm_available: true".
return ctx.ModuleContext.DeviceSpecific() || (ctx.RustModule().InVendor() && ctx.RustModule().VendorVariantToOdm()) return mod.InVendor() && mod.VendorVariantToOdm()
}
func (ctx *moduleContext) SystemExtSpecific() bool {
return ctx.ModuleContext.SystemExtSpecific()
} }
// Returns true when this module creates a vendor variant and wants to install the vendor variant // Returns true when this module creates a vendor variant and wants to install the vendor variant