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

Commit 79b0eef5 authored by Jihoon Kang's avatar Jihoon Kang Committed by Gerrit Code Review
Browse files

Merge "Move vendor and product variant generation logic from cc package to...

Merge "Move vendor and product variant generation logic from cc package to android package" into main
parents cd2604b0 47e91845
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -19,6 +19,12 @@ type ImageInterface interface {
	// ImageMutatorBegin is called before any other method in the ImageInterface.
	ImageMutatorBegin(ctx BaseModuleContext)

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

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

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

@@ -49,6 +55,14 @@ type ImageInterface interface {
}

const (
	// VendorVariation is the variant name used for /vendor code that does not
	// compile against the VNDK.
	VendorVariation string = "vendor"

	// ProductVariation is the variant name used for /product code that does not
	// compile against the VNDK.
	ProductVariation string = "product"

	// CoreVariation is the variant used for framework-private libraries, or
	// SDK libraries. (which framework-private libraries can use), which
	// will be installed to the system image.
@@ -94,6 +108,12 @@ func imageMutator(ctx BottomUpMutatorContext) {
		if m.RecoveryVariantNeeded(ctx) {
			variations = append(variations, RecoveryVariation)
		}
		if m.VendorVariantNeeded(ctx) {
			variations = append(variations, VendorVariation)
		}
		if m.ProductVariantNeeded(ctx) {
			variations = append(variations, ProductVariation)
		}

		extraVariations := m.ExtraImageVariations(ctx)
		variations = append(variations, extraVariations...)
+2 −2
Original line number Diff line number Diff line
@@ -748,9 +748,9 @@ func (a *apexBundle) getImageVariationPair() (string, string) {

	prefix := android.CoreVariation
	if a.SocSpecific() || a.DeviceSpecific() {
		prefix = cc.VendorVariation
		prefix = android.VendorVariation
	} else if a.ProductSpecific() {
		prefix = cc.ProductVariation
		prefix = android.ProductVariation
	}

	return prefix, ""
+8 −3
Original line number Diff line number Diff line
@@ -104,6 +104,14 @@ var _ android.ImageInterface = (*bpf)(nil)

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

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

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

func (bpf *bpf) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
	return !proptools.Bool(bpf.properties.Vendor)
}
@@ -125,9 +133,6 @@ func (bpf *bpf) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
}

func (bpf *bpf) ExtraImageVariations(ctx android.BaseModuleContext) []string {
	if proptools.Bool(bpf.properties.Vendor) {
		return []string{"vendor"}
	}
	return nil
}

+3 −1
Original line number Diff line number Diff line
@@ -361,6 +361,8 @@ type BaseProperties struct {
	Recovery_available *bool

	// Used by imageMutator, set by ImageMutatorBegin()
	VendorVariantNeeded        bool `blueprint:"mutated"`
	ProductVariantNeeded       bool `blueprint:"mutated"`
	CoreVariantNeeded          bool `blueprint:"mutated"`
	RamdiskVariantNeeded       bool `blueprint:"mutated"`
	VendorRamdiskVariantNeeded bool `blueprint:"mutated"`
@@ -2509,7 +2511,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
	if c.ImageVariation().Variation == android.CoreVariation && c.Device() &&
		c.Target().NativeBridge == android.NativeBridgeDisabled {
		actx.AddVariationDependencies(
			[]blueprint.Variation{{Mutator: "image", Variation: VendorVariation}},
			[]blueprint.Variation{{Mutator: "image", Variation: android.VendorVariation}},
			llndkHeaderLibTag,
			deps.LlndkHeaderLibs...)
	}
+9 −12
Original line number Diff line number Diff line
@@ -79,6 +79,14 @@ var _ android.ImageInterface = (*GenruleExtraProperties)(nil)

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

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

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

func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
	return !(ctx.SocSpecific() || ctx.DeviceSpecific() || ctx.ProductSpecific())
}
@@ -102,18 +110,7 @@ func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleCon
}

func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string {
	var variants []string
	vendorVariantRequired := Bool(g.Vendor_available) || Bool(g.Odm_available) || ctx.SocSpecific() || ctx.DeviceSpecific()
	productVariantRequired := Bool(g.Product_available) || ctx.ProductSpecific()

	if vendorVariantRequired {
		variants = append(variants, VendorVariation)
	}
	if productVariantRequired {
		variants = append(variants, ProductVariation)
	}

	return variants
	return nil
}

func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string) {
Loading