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

Commit fc7a4112 authored by Cole Faust's avatar Cole Faust
Browse files

Add NeverFar() option for transition mutators

Far variation dependencies ignore all of the source module's variations
when adding a dependency. However, there are some mutators, like the
base config mutator, that want to ensure their dependencies always
stay within the same variant. Add the ability to tag those mutators
as NeverFar mutators, so that when adding a far dependency, those
variants will still be included in the requirements for the dependency.

Bug: 361816274
Test: m nothing --no-skip-soong-tests
Change-Id: I5900d603513ccf1a4938d164c02775d650875e9b
parent bd44fd7e
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ type RegisterMutatorsContext interface {
	TopDown(name string, m TopDownMutator) MutatorHandle
	BottomUp(name string, m BottomUpMutator) MutatorHandle
	BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle
	Transition(name string, m TransitionMutator)
	Transition(name string, m TransitionMutator) TransitionMutatorHandle
}

type RegisterMutatorFunc func(RegisterMutatorsContext)
@@ -579,7 +579,7 @@ func (a *androidTransitionMutator) Mutate(ctx blueprint.BottomUpMutatorContext,
	}
}

func (x *registerMutatorsContext) Transition(name string, m TransitionMutator) {
func (x *registerMutatorsContext) Transition(name string, m TransitionMutator) TransitionMutatorHandle {
	atm := &androidTransitionMutator{
		finalPhase: x.finalPhase,
		mutator:    m,
@@ -587,8 +587,10 @@ func (x *registerMutatorsContext) Transition(name string, m TransitionMutator) {
	}
	mutator := &mutator{
		name:              name,
		transitionMutator: atm}
		transitionMutator: atm,
	}
	x.mutators = append(x.mutators, mutator)
	return mutator
}

func (x *registerMutatorsContext) mutatorName(name string) string {
@@ -625,7 +627,10 @@ func (mutator *mutator) register(ctx *Context) {
	} else if mutator.topDownMutator != nil {
		handle = blueprintCtx.RegisterTopDownMutator(mutator.name, mutator.topDownMutator)
	} else if mutator.transitionMutator != nil {
		blueprintCtx.RegisterTransitionMutator(mutator.name, mutator.transitionMutator)
		handle := blueprintCtx.RegisterTransitionMutator(mutator.name, mutator.transitionMutator)
		if mutator.neverFar {
			handle.NeverFar()
		}
	}

	// Forward booleans set on the MutatorHandle to the blueprint.MutatorHandle.
@@ -681,6 +686,14 @@ type MutatorHandle interface {
	MutatesGlobalState() MutatorHandle
}

type TransitionMutatorHandle interface {
	// NeverFar causes the variations created by this mutator to never be ignored when adding
	// far variation dependencies. Normally, far variation dependencies ignore all the variants
	// of the source module, and only use the variants explicitly requested by the
	// AddFarVariationDependencies call.
	NeverFar() MutatorHandle
}

func (mutator *mutator) Parallel() MutatorHandle {
	return mutator
}
@@ -715,6 +728,11 @@ func (mutator *mutator) MutatesGlobalState() MutatorHandle {
	return mutator
}

func (mutator *mutator) NeverFar() MutatorHandle {
	mutator.neverFar = true
	return mutator
}

func RegisterComponentsMutator(ctx RegisterMutatorsContext) {
	ctx.BottomUp("component-deps", componentDepsMutator)
}
+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ type mutator struct {
	usesCreateModule        bool
	mutatesDependencies     bool
	mutatesGlobalState      bool
	neverFar                bool
}

var _ sortableComponent = &mutator{}