Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33d6ebcf authored by Cole Faust's avatar Cole Faust Committed by Gerrit Code Review
Browse files

Merge "Make ImageInterface use its own context" into main

parents 4aa7e331 fa6e0fdf
Loading
Loading
Loading
Loading
+27 −10
Original line number Diff line number Diff line
@@ -14,44 +14,61 @@

package android

type ImageInterfaceContext interface {
	ArchModuleContext

	Module() Module

	ModuleErrorf(fmt string, args ...interface{})
	PropertyErrorf(property, fmt string, args ...interface{})

	DeviceSpecific() bool
	SocSpecific() bool
	ProductSpecific() bool
	SystemExtSpecific() bool
	Platform() bool

	Config() Config
}

// ImageInterface is implemented by modules that need to be split by the imageTransitionMutator.
type ImageInterface interface {
	// ImageMutatorBegin is called before any other method in the ImageInterface.
	ImageMutatorBegin(ctx BaseModuleContext)
	ImageMutatorBegin(ctx ImageInterfaceContext)

	// VendorVariantNeeded should return true if the module needs a vendor variant (installed on the vendor image).
	VendorVariantNeeded(ctx BaseModuleContext) bool
	VendorVariantNeeded(ctx ImageInterfaceContext) bool

	// ProductVariantNeeded should return true if the module needs a product variant (installed on the product image).
	ProductVariantNeeded(ctx BaseModuleContext) bool
	ProductVariantNeeded(ctx ImageInterfaceContext) bool

	// CoreVariantNeeded should return true if the module needs a core variant (installed on the system image).
	CoreVariantNeeded(ctx BaseModuleContext) bool
	CoreVariantNeeded(ctx ImageInterfaceContext) bool

	// RamdiskVariantNeeded should return true if the module needs a ramdisk variant (installed on the
	// ramdisk partition).
	RamdiskVariantNeeded(ctx BaseModuleContext) bool
	RamdiskVariantNeeded(ctx ImageInterfaceContext) bool

	// VendorRamdiskVariantNeeded should return true if the module needs a vendor ramdisk variant (installed on the
	// vendor ramdisk partition).
	VendorRamdiskVariantNeeded(ctx BaseModuleContext) bool
	VendorRamdiskVariantNeeded(ctx ImageInterfaceContext) bool

	// DebugRamdiskVariantNeeded should return true if the module needs a debug ramdisk variant (installed on the
	// debug ramdisk partition: $(PRODUCT_OUT)/debug_ramdisk).
	DebugRamdiskVariantNeeded(ctx BaseModuleContext) bool
	DebugRamdiskVariantNeeded(ctx ImageInterfaceContext) bool

	// RecoveryVariantNeeded should return true if the module needs a recovery variant (installed on the
	// recovery partition).
	RecoveryVariantNeeded(ctx BaseModuleContext) bool
	RecoveryVariantNeeded(ctx ImageInterfaceContext) bool

	// ExtraImageVariations should return a list of the additional variations needed for the module.  After the
	// variants are created the SetImageVariation method will be called on each newly created variant with the
	// its variation.
	ExtraImageVariations(ctx BaseModuleContext) []string
	ExtraImageVariations(ctx ImageInterfaceContext) []string

	// SetImageVariation is called for each newly created image variant. The receiver is the original
	// module, "variation" is the name of the newly created variant. "variation" is set on the receiver.
	SetImageVariation(ctx BaseModuleContext, variation string)
	SetImageVariation(ctx ImageInterfaceContext, variation string)
}

const (
+10 −10
Original line number Diff line number Diff line
@@ -109,41 +109,41 @@ type bpf struct {

var _ android.ImageInterface = (*bpf)(nil)

func (bpf *bpf) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (bpf *bpf) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}

func (bpf *bpf) VendorVariantNeeded(ctx android.BaseModuleContext) bool {
func (bpf *bpf) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return proptools.Bool(bpf.properties.Vendor)
}

func (bpf *bpf) ProductVariantNeeded(ctx android.BaseModuleContext) bool {
func (bpf *bpf) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (bpf *bpf) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
func (bpf *bpf) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return !proptools.Bool(bpf.properties.Vendor)
}

func (bpf *bpf) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (bpf *bpf) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (bpf *bpf) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (bpf *bpf) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (bpf *bpf) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (bpf *bpf) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (bpf *bpf) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
func (bpf *bpf) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (bpf *bpf) ExtraImageVariations(ctx android.BaseModuleContext) []string {
func (bpf *bpf) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
	return nil
}

func (bpf *bpf) SetImageVariation(ctx android.BaseModuleContext, variation string) {
func (bpf *bpf) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
	bpf.properties.VendorInternal = variation == "vendor"
}

+10 −10
Original line number Diff line number Diff line
@@ -104,41 +104,41 @@ type libbpfProg struct {

var _ android.ImageInterface = (*libbpfProg)(nil)

func (libbpf *libbpfProg) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (libbpf *libbpfProg) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}

func (libbpf *libbpfProg) VendorVariantNeeded(ctx android.BaseModuleContext) bool {
func (libbpf *libbpfProg) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (libbpf *libbpfProg) ProductVariantNeeded(ctx android.BaseModuleContext) bool {
func (libbpf *libbpfProg) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (libbpf *libbpfProg) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
func (libbpf *libbpfProg) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return true
}

func (libbpf *libbpfProg) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (libbpf *libbpfProg) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (libbpf *libbpfProg) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (libbpf *libbpfProg) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (libbpf *libbpfProg) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (libbpf *libbpfProg) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (libbpf *libbpfProg) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
func (libbpf *libbpfProg) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (libbpf *libbpfProg) ExtraImageVariations(ctx android.BaseModuleContext) []string {
func (libbpf *libbpfProg) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
	return nil
}

func (libbpf *libbpfProg) SetImageVariation(ctx android.BaseModuleContext, variation string) {
func (libbpf *libbpfProg) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
}

func (libbpf *libbpfProg) DepsMutator(ctx android.BottomUpMutatorContext) {
+10 −10
Original line number Diff line number Diff line
@@ -77,41 +77,41 @@ func genruleCmdModifier(ctx android.ModuleContext, cmd string) string {

var _ android.ImageInterface = (*GenruleExtraProperties)(nil)

func (g *GenruleExtraProperties) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (g *GenruleExtraProperties) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}

func (g *GenruleExtraProperties) VendorVariantNeeded(ctx android.BaseModuleContext) bool {
func (g *GenruleExtraProperties) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return Bool(g.Vendor_available) || Bool(g.Odm_available) || ctx.SocSpecific() || ctx.DeviceSpecific()
}

func (g *GenruleExtraProperties) ProductVariantNeeded(ctx android.BaseModuleContext) bool {
func (g *GenruleExtraProperties) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return Bool(g.Product_available) || ctx.ProductSpecific()
}

func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return !(ctx.SocSpecific() || ctx.DeviceSpecific() || ctx.ProductSpecific())
}

func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return Bool(g.Ramdisk_available)
}

func (g *GenruleExtraProperties) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (g *GenruleExtraProperties) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return Bool(g.Vendor_ramdisk_available)
}

func (g *GenruleExtraProperties) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (g *GenruleExtraProperties) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
	// If the build is using a snapshot, the recovery variant under AOSP directories
	// is not needed.
	return Bool(g.Recovery_available)
}

func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string {
func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
	return nil
}

func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string) {
func (g *GenruleExtraProperties) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
}
+13 −13
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ type ImageMutatableModule interface {
	IsSnapshotPrebuilt() bool

	// SnapshotVersion returns the snapshot version for this module.
	SnapshotVersion(mctx android.BaseModuleContext) string
	SnapshotVersion(mctx android.ImageInterfaceContext) string

	// SdkVersion returns the SDK version for this module.
	SdkVersion() string
@@ -209,7 +209,7 @@ type ImageMutatableModule interface {

var _ ImageMutatableModule = (*Module)(nil)

func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
func (m *Module) ImageMutatorBegin(mctx android.ImageInterfaceContext) {
	MutateImage(mctx, m)
}

@@ -273,7 +273,7 @@ func (m *Module) SetVendorVariantNeeded(b bool) {
	m.Properties.VendorVariantNeeded = b
}

func (m *Module) SnapshotVersion(mctx android.BaseModuleContext) string {
func (m *Module) SnapshotVersion(mctx android.ImageInterfaceContext) string {
	if snapshot, ok := m.linker.(SnapshotInterface); ok {
		return snapshot.Version()
	} else {
@@ -291,7 +291,7 @@ func (m *Module) KernelHeadersDecorator() bool {
}

// MutateImage handles common image mutations for ImageMutatableModule interfaces.
func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
func MutateImage(mctx android.ImageInterfaceContext, m ImageMutatableModule) {
	// Validation check
	vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
	productSpecific := mctx.ProductSpecific()
@@ -431,35 +431,35 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
	}
}

func (c *Module) VendorVariantNeeded(ctx android.BaseModuleContext) bool {
func (c *Module) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return c.Properties.VendorVariantNeeded
}

func (c *Module) ProductVariantNeeded(ctx android.BaseModuleContext) bool {
func (c *Module) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return c.Properties.ProductVariantNeeded
}

func (c *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
func (c *Module) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return c.Properties.CoreVariantNeeded
}

func (c *Module) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (c *Module) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return c.Properties.RamdiskVariantNeeded
}

func (c *Module) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (c *Module) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return c.Properties.VendorRamdiskVariantNeeded
}

func (c *Module) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
func (c *Module) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return false
}

func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
func (c *Module) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
	return c.Properties.RecoveryVariantNeeded
}

func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
func (c *Module) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
	return c.Properties.ExtraVersionedImageVariations
}

@@ -513,7 +513,7 @@ func squashRamdiskSrcs(m *Module) {
	}
}

func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) {
func (c *Module) SetImageVariation(ctx android.ImageInterfaceContext, variant string) {
	if variant == android.RamdiskVariation {
		c.MakeAsPlatform()
		squashRamdiskSrcs(c)
Loading