Add ArchModuleContext to TransitionMutator contexts
Converting coverageMutator to a TransitionMutator requires adding the ctx.Device() and ctx.DeviceConfig() methods. Bug: 319288033 Test: builds Change-Id: I697b48eb89bc23800d2d3c62d68358769f0d1075
This commit is contained in:
parent
1d3d9f13b8
commit
4aa3e0ab81
2 changed files with 48 additions and 15 deletions
|
@ -1627,7 +1627,7 @@ func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) archModuleContextFactory(ctx blueprint.EarlyModuleContext) archModuleContext {
|
func (m *ModuleBase) archModuleContextFactory(ctx blueprint.IncomingTransitionContext) archModuleContext {
|
||||||
config := ctx.Config().(Config)
|
config := ctx.Config().(Config)
|
||||||
target := m.Target()
|
target := m.Target()
|
||||||
primaryArch := false
|
primaryArch := false
|
||||||
|
|
|
@ -365,15 +365,21 @@ func (x *registerMutatorsContext) BottomUpBlueprint(name string, m blueprint.Bot
|
||||||
}
|
}
|
||||||
|
|
||||||
type IncomingTransitionContext interface {
|
type IncomingTransitionContext interface {
|
||||||
|
ArchModuleContext
|
||||||
|
|
||||||
// Module returns the target of the dependency edge for which the transition
|
// Module returns the target of the dependency edge for which the transition
|
||||||
// is being computed
|
// is being computed
|
||||||
Module() Module
|
Module() Module
|
||||||
|
|
||||||
// Config returns the configuration for the build.
|
// Config returns the configuration for the build.
|
||||||
Config() Config
|
Config() Config
|
||||||
|
|
||||||
|
DeviceConfig() DeviceConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type OutgoingTransitionContext interface {
|
type OutgoingTransitionContext interface {
|
||||||
|
ArchModuleContext
|
||||||
|
|
||||||
// Module returns the target of the dependency edge for which the transition
|
// Module returns the target of the dependency edge for which the transition
|
||||||
// is being computed
|
// is being computed
|
||||||
Module() Module
|
Module() Module
|
||||||
|
@ -381,9 +387,14 @@ type OutgoingTransitionContext interface {
|
||||||
// DepTag() Returns the dependency tag through which this dependency is
|
// DepTag() Returns the dependency tag through which this dependency is
|
||||||
// reached
|
// reached
|
||||||
DepTag() blueprint.DependencyTag
|
DepTag() blueprint.DependencyTag
|
||||||
|
|
||||||
|
// Config returns the configuration for the build.
|
||||||
|
Config() Config
|
||||||
|
|
||||||
|
DeviceConfig() DeviceConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transition mutators implement a top-down mechanism where a module tells its
|
// TransitionMutator implements a top-down mechanism where a module tells its
|
||||||
// direct dependencies what variation they should be built in but the dependency
|
// direct dependencies what variation they should be built in but the dependency
|
||||||
// has the final say.
|
// has the final say.
|
||||||
//
|
//
|
||||||
|
@ -448,18 +459,18 @@ type TransitionMutator interface {
|
||||||
// called on.
|
// called on.
|
||||||
Split(ctx BaseModuleContext) []string
|
Split(ctx BaseModuleContext) []string
|
||||||
|
|
||||||
// Called on a module to determine which variation it wants from its direct
|
// OutgoingTransition is called on a module to determine which variation it wants
|
||||||
// dependencies. The dependency itself can override this decision. This method
|
// from its direct dependencies. The dependency itself can override this decision.
|
||||||
// should not mutate the module itself.
|
// This method should not mutate the module itself.
|
||||||
OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string
|
OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string
|
||||||
|
|
||||||
// Called on a module to determine which variation it should be in based on
|
// IncomingTransition is called on a module to determine which variation it should
|
||||||
// the variation modules that depend on it want. This gives the module a final
|
// be in based on the variation modules that depend on it want. This gives the module
|
||||||
// say about its own variations. This method should not mutate the module
|
// a final say about its own variations. This method should not mutate the module
|
||||||
// itself.
|
// itself.
|
||||||
IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string
|
IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string
|
||||||
|
|
||||||
// Called after a module was split into multiple variations on each variation.
|
// Mutate is called after a module was split into multiple variations on each variation.
|
||||||
// It should not split the module any further but adding new dependencies is
|
// It should not split the module any further but adding new dependencies is
|
||||||
// fine. Unlike all the other methods on TransitionMutator, this method is
|
// fine. Unlike all the other methods on TransitionMutator, this method is
|
||||||
// allowed to mutate the module.
|
// allowed to mutate the module.
|
||||||
|
@ -481,6 +492,7 @@ func (a *androidTransitionMutator) Split(ctx blueprint.BaseModuleContext) []stri
|
||||||
}
|
}
|
||||||
|
|
||||||
type outgoingTransitionContextImpl struct {
|
type outgoingTransitionContextImpl struct {
|
||||||
|
archModuleContext
|
||||||
bp blueprint.OutgoingTransitionContext
|
bp blueprint.OutgoingTransitionContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,15 +504,28 @@ func (c *outgoingTransitionContextImpl) DepTag() blueprint.DependencyTag {
|
||||||
return c.bp.DepTag()
|
return c.bp.DepTag()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *androidTransitionMutator) OutgoingTransition(ctx blueprint.OutgoingTransitionContext, sourceVariation string) string {
|
func (c *outgoingTransitionContextImpl) Config() Config {
|
||||||
if _, ok := ctx.Module().(Module); ok {
|
return c.bp.Config().(Config)
|
||||||
return a.mutator.OutgoingTransition(&outgoingTransitionContextImpl{bp: ctx}, sourceVariation)
|
}
|
||||||
|
|
||||||
|
func (c *outgoingTransitionContextImpl) DeviceConfig() DeviceConfig {
|
||||||
|
return DeviceConfig{c.bp.Config().(Config).deviceConfig}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *androidTransitionMutator) OutgoingTransition(bpctx blueprint.OutgoingTransitionContext, sourceVariation string) string {
|
||||||
|
if m, ok := bpctx.Module().(Module); ok {
|
||||||
|
ctx := &outgoingTransitionContextImpl{
|
||||||
|
archModuleContext: m.base().archModuleContextFactory(bpctx),
|
||||||
|
bp: bpctx,
|
||||||
|
}
|
||||||
|
return a.mutator.OutgoingTransition(ctx, sourceVariation)
|
||||||
} else {
|
} else {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type incomingTransitionContextImpl struct {
|
type incomingTransitionContextImpl struct {
|
||||||
|
archModuleContext
|
||||||
bp blueprint.IncomingTransitionContext
|
bp blueprint.IncomingTransitionContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,9 +537,17 @@ func (c *incomingTransitionContextImpl) Config() Config {
|
||||||
return c.bp.Config().(Config)
|
return c.bp.Config().(Config)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *androidTransitionMutator) IncomingTransition(ctx blueprint.IncomingTransitionContext, incomingVariation string) string {
|
func (c *incomingTransitionContextImpl) DeviceConfig() DeviceConfig {
|
||||||
if _, ok := ctx.Module().(Module); ok {
|
return DeviceConfig{c.bp.Config().(Config).deviceConfig}
|
||||||
return a.mutator.IncomingTransition(&incomingTransitionContextImpl{bp: ctx}, incomingVariation)
|
}
|
||||||
|
|
||||||
|
func (a *androidTransitionMutator) IncomingTransition(bpctx blueprint.IncomingTransitionContext, incomingVariation string) string {
|
||||||
|
if m, ok := bpctx.Module().(Module); ok {
|
||||||
|
ctx := &incomingTransitionContextImpl{
|
||||||
|
archModuleContext: m.base().archModuleContextFactory(bpctx),
|
||||||
|
bp: bpctx,
|
||||||
|
}
|
||||||
|
return a.mutator.IncomingTransition(ctx, incomingVariation)
|
||||||
} else {
|
} else {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue