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)
|
||||
target := m.Target()
|
||||
primaryArch := false
|
||||
|
|
|
@ -365,15 +365,21 @@ func (x *registerMutatorsContext) BottomUpBlueprint(name string, m blueprint.Bot
|
|||
}
|
||||
|
||||
type IncomingTransitionContext interface {
|
||||
ArchModuleContext
|
||||
|
||||
// Module returns the target of the dependency edge for which the transition
|
||||
// is being computed
|
||||
Module() Module
|
||||
|
||||
// Config returns the configuration for the build.
|
||||
Config() Config
|
||||
|
||||
DeviceConfig() DeviceConfig
|
||||
}
|
||||
|
||||
type OutgoingTransitionContext interface {
|
||||
ArchModuleContext
|
||||
|
||||
// Module returns the target of the dependency edge for which the transition
|
||||
// is being computed
|
||||
Module() Module
|
||||
|
@ -381,9 +387,14 @@ type OutgoingTransitionContext interface {
|
|||
// DepTag() Returns the dependency tag through which this dependency is
|
||||
// reached
|
||||
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
|
||||
// has the final say.
|
||||
//
|
||||
|
@ -448,18 +459,18 @@ type TransitionMutator interface {
|
|||
// called on.
|
||||
Split(ctx BaseModuleContext) []string
|
||||
|
||||
// Called on a module to determine which variation it wants from its direct
|
||||
// dependencies. The dependency itself can override this decision. This method
|
||||
// should not mutate the module itself.
|
||||
// OutgoingTransition is called on a module to determine which variation it wants
|
||||
// from its direct dependencies. The dependency itself can override this decision.
|
||||
// This method should not mutate the module itself.
|
||||
OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string
|
||||
|
||||
// Called on a module to determine which variation it should be in based on
|
||||
// the variation modules that depend on it want. This gives the module a final
|
||||
// say about its own variations. This method should not mutate the module
|
||||
// IncomingTransition is called on a module to determine which variation it should
|
||||
// be in based on the variation modules that depend on it want. This gives the module
|
||||
// a final say about its own variations. This method should not mutate the module
|
||||
// itself.
|
||||
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
|
||||
// fine. Unlike all the other methods on TransitionMutator, this method is
|
||||
// allowed to mutate the module.
|
||||
|
@ -481,6 +492,7 @@ func (a *androidTransitionMutator) Split(ctx blueprint.BaseModuleContext) []stri
|
|||
}
|
||||
|
||||
type outgoingTransitionContextImpl struct {
|
||||
archModuleContext
|
||||
bp blueprint.OutgoingTransitionContext
|
||||
}
|
||||
|
||||
|
@ -492,15 +504,28 @@ func (c *outgoingTransitionContextImpl) DepTag() blueprint.DependencyTag {
|
|||
return c.bp.DepTag()
|
||||
}
|
||||
|
||||
func (a *androidTransitionMutator) OutgoingTransition(ctx blueprint.OutgoingTransitionContext, sourceVariation string) string {
|
||||
if _, ok := ctx.Module().(Module); ok {
|
||||
return a.mutator.OutgoingTransition(&outgoingTransitionContextImpl{bp: ctx}, sourceVariation)
|
||||
func (c *outgoingTransitionContextImpl) Config() Config {
|
||||
return c.bp.Config().(Config)
|
||||
}
|
||||
|
||||
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 {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
type incomingTransitionContextImpl struct {
|
||||
archModuleContext
|
||||
bp blueprint.IncomingTransitionContext
|
||||
}
|
||||
|
||||
|
@ -512,9 +537,17 @@ func (c *incomingTransitionContextImpl) Config() Config {
|
|||
return c.bp.Config().(Config)
|
||||
}
|
||||
|
||||
func (a *androidTransitionMutator) IncomingTransition(ctx blueprint.IncomingTransitionContext, incomingVariation string) string {
|
||||
if _, ok := ctx.Module().(Module); ok {
|
||||
return a.mutator.IncomingTransition(&incomingTransitionContextImpl{bp: ctx}, incomingVariation)
|
||||
func (c *incomingTransitionContextImpl) DeviceConfig() DeviceConfig {
|
||||
return DeviceConfig{c.bp.Config().(Config).deviceConfig}
|
||||
}
|
||||
|
||||
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 {
|
||||
return ""
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue