Merge "Handle nil variant in applyTransitions" into main
This commit is contained in:
commit
515e7991fc
2 changed files with 35 additions and 6 deletions
|
@ -1877,7 +1877,7 @@ func (c *Context) findReverseDependency(module *moduleInfo, config any, destName
|
||||||
// modify the requested variation. It finds a variant that existed before the TransitionMutator ran that is
|
// modify the requested variation. It finds a variant that existed before the TransitionMutator ran that is
|
||||||
// a subset of the requested variant to use as the module context for IncomingTransition.
|
// a subset of the requested variant to use as the module context for IncomingTransition.
|
||||||
func (c *Context) applyTransitions(config any, module *moduleInfo, group *moduleGroup, variant variationMap,
|
func (c *Context) applyTransitions(config any, module *moduleInfo, group *moduleGroup, variant variationMap,
|
||||||
requestedVariations []Variation) {
|
requestedVariations []Variation) variationMap {
|
||||||
for _, transitionMutator := range c.transitionMutators {
|
for _, transitionMutator := range c.transitionMutators {
|
||||||
// Apply the outgoing transition if it was not explicitly requested.
|
// Apply the outgoing transition if it was not explicitly requested.
|
||||||
explicitlyRequested := slices.ContainsFunc(requestedVariations, func(variation Variation) bool {
|
explicitlyRequested := slices.ContainsFunc(requestedVariations, func(variation Variation) bool {
|
||||||
|
@ -1903,6 +1903,9 @@ func (c *Context) applyTransitions(config any, module *moduleInfo, group *module
|
||||||
}
|
}
|
||||||
|
|
||||||
finalVariation := transitionMutator.mutator.IncomingTransition(ctx, outgoingVariation)
|
finalVariation := transitionMutator.mutator.IncomingTransition(ctx, outgoingVariation)
|
||||||
|
if variant == nil {
|
||||||
|
variant = make(variationMap)
|
||||||
|
}
|
||||||
variant[transitionMutator.name] = finalVariation
|
variant[transitionMutator.name] = finalVariation
|
||||||
appliedIncomingTransition = true
|
appliedIncomingTransition = true
|
||||||
break
|
break
|
||||||
|
@ -1914,6 +1917,8 @@ func (c *Context) applyTransitions(config any, module *moduleInfo, group *module
|
||||||
delete(variant, transitionMutator.name)
|
delete(variant, transitionMutator.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return variant
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) findVariant(module *moduleInfo, config any,
|
func (c *Context) findVariant(module *moduleInfo, config any,
|
||||||
|
@ -1940,7 +1945,7 @@ func (c *Context) findVariant(module *moduleInfo, config any,
|
||||||
newVariant[v.Mutator] = v.Variation
|
newVariant[v.Mutator] = v.Variation
|
||||||
}
|
}
|
||||||
|
|
||||||
c.applyTransitions(config, module, possibleDeps, newVariant, requestedVariations)
|
newVariant = c.applyTransitions(config, module, possibleDeps, newVariant, requestedVariations)
|
||||||
|
|
||||||
check := func(variant variationMap) bool {
|
check := func(variant variationMap) bool {
|
||||||
if far {
|
if far {
|
||||||
|
|
|
@ -86,7 +86,18 @@ const testTransitionBp = `
|
||||||
}
|
}
|
||||||
|
|
||||||
transition_module {
|
transition_module {
|
||||||
name: "F"
|
name: "F",
|
||||||
|
}
|
||||||
|
|
||||||
|
transition_module {
|
||||||
|
name: "G",
|
||||||
|
outgoing: "h",
|
||||||
|
%s
|
||||||
|
}
|
||||||
|
|
||||||
|
transition_module {
|
||||||
|
name: "H",
|
||||||
|
split: ["h"],
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -128,7 +139,7 @@ func checkTransitionMutate(t *testing.T, m *transitionModule, variant string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTransition(t *testing.T) {
|
func TestTransition(t *testing.T) {
|
||||||
ctx, errs := testTransition(fmt.Sprintf(testTransitionBp, ""))
|
ctx, errs := testTransition(fmt.Sprintf(testTransitionBp, "", ""))
|
||||||
assertNoErrors(t, errs)
|
assertNoErrors(t, errs)
|
||||||
|
|
||||||
// Module A uses Split to create a and b variants
|
// Module A uses Split to create a and b variants
|
||||||
|
@ -154,6 +165,8 @@ func TestTransition(t *testing.T) {
|
||||||
D_d := getTransitionModule(ctx, "D", "d")
|
D_d := getTransitionModule(ctx, "D", "d")
|
||||||
E_d := getTransitionModule(ctx, "E", "d")
|
E_d := getTransitionModule(ctx, "E", "d")
|
||||||
F := getTransitionModule(ctx, "F", "")
|
F := getTransitionModule(ctx, "F", "")
|
||||||
|
G := getTransitionModule(ctx, "G", "")
|
||||||
|
H_h := getTransitionModule(ctx, "H", "h")
|
||||||
|
|
||||||
checkTransitionDeps(t, ctx, A_a, "B(a)", "C(a)")
|
checkTransitionDeps(t, ctx, A_a, "B(a)", "C(a)")
|
||||||
checkTransitionDeps(t, ctx, A_b, "B(b)", "C(b)")
|
checkTransitionDeps(t, ctx, A_b, "B(b)", "C(b)")
|
||||||
|
@ -165,6 +178,8 @@ func TestTransition(t *testing.T) {
|
||||||
checkTransitionDeps(t, ctx, D_d, "E(d)")
|
checkTransitionDeps(t, ctx, D_d, "E(d)")
|
||||||
checkTransitionDeps(t, ctx, E_d)
|
checkTransitionDeps(t, ctx, E_d)
|
||||||
checkTransitionDeps(t, ctx, F)
|
checkTransitionDeps(t, ctx, F)
|
||||||
|
checkTransitionDeps(t, ctx, G)
|
||||||
|
checkTransitionDeps(t, ctx, H_h)
|
||||||
|
|
||||||
checkTransitionMutate(t, A_a, "a")
|
checkTransitionMutate(t, A_a, "a")
|
||||||
checkTransitionMutate(t, A_b, "b")
|
checkTransitionMutate(t, A_b, "b")
|
||||||
|
@ -176,11 +191,14 @@ func TestTransition(t *testing.T) {
|
||||||
checkTransitionMutate(t, D_d, "d")
|
checkTransitionMutate(t, D_d, "d")
|
||||||
checkTransitionMutate(t, E_d, "d")
|
checkTransitionMutate(t, E_d, "d")
|
||||||
checkTransitionMutate(t, F, "")
|
checkTransitionMutate(t, F, "")
|
||||||
|
checkTransitionMutate(t, G, "")
|
||||||
|
checkTransitionMutate(t, H_h, "h")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPostTransitionDeps(t *testing.T) {
|
func TestPostTransitionDeps(t *testing.T) {
|
||||||
ctx, errs := testTransition(fmt.Sprintf(testTransitionBp,
|
ctx, errs := testTransition(fmt.Sprintf(testTransitionBp,
|
||||||
`post_transition_deps: ["C", "D:late", "E:d", "F"],`))
|
`post_transition_deps: ["C", "D:late", "E:d", "F"],`,
|
||||||
|
`post_transition_deps: ["H"],`))
|
||||||
assertNoErrors(t, errs)
|
assertNoErrors(t, errs)
|
||||||
|
|
||||||
// Module A uses Split to create a and b variants
|
// Module A uses Split to create a and b variants
|
||||||
|
@ -206,6 +224,8 @@ func TestPostTransitionDeps(t *testing.T) {
|
||||||
D_d := getTransitionModule(ctx, "D", "d")
|
D_d := getTransitionModule(ctx, "D", "d")
|
||||||
E_d := getTransitionModule(ctx, "E", "d")
|
E_d := getTransitionModule(ctx, "E", "d")
|
||||||
F := getTransitionModule(ctx, "F", "")
|
F := getTransitionModule(ctx, "F", "")
|
||||||
|
G := getTransitionModule(ctx, "G", "")
|
||||||
|
H_h := getTransitionModule(ctx, "H", "h")
|
||||||
|
|
||||||
checkTransitionDeps(t, ctx, A_a, "B(a)", "C(a)")
|
checkTransitionDeps(t, ctx, A_a, "B(a)", "C(a)")
|
||||||
checkTransitionDeps(t, ctx, A_b, "B(b)", "C(b)")
|
checkTransitionDeps(t, ctx, A_b, "B(b)", "C(b)")
|
||||||
|
@ -222,6 +242,8 @@ func TestPostTransitionDeps(t *testing.T) {
|
||||||
checkTransitionDeps(t, ctx, D_d, "E(d)")
|
checkTransitionDeps(t, ctx, D_d, "E(d)")
|
||||||
checkTransitionDeps(t, ctx, E_d)
|
checkTransitionDeps(t, ctx, E_d)
|
||||||
checkTransitionDeps(t, ctx, F)
|
checkTransitionDeps(t, ctx, F)
|
||||||
|
checkTransitionDeps(t, ctx, G, "H(h)")
|
||||||
|
checkTransitionDeps(t, ctx, H_h)
|
||||||
|
|
||||||
checkTransitionMutate(t, A_a, "a")
|
checkTransitionMutate(t, A_a, "a")
|
||||||
checkTransitionMutate(t, A_b, "b")
|
checkTransitionMutate(t, A_b, "b")
|
||||||
|
@ -233,12 +255,14 @@ func TestPostTransitionDeps(t *testing.T) {
|
||||||
checkTransitionMutate(t, D_d, "d")
|
checkTransitionMutate(t, D_d, "d")
|
||||||
checkTransitionMutate(t, E_d, "d")
|
checkTransitionMutate(t, E_d, "d")
|
||||||
checkTransitionMutate(t, F, "")
|
checkTransitionMutate(t, F, "")
|
||||||
|
checkTransitionMutate(t, G, "")
|
||||||
|
checkTransitionMutate(t, H_h, "h")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPostTransitionDepsMissingVariant(t *testing.T) {
|
func TestPostTransitionDepsMissingVariant(t *testing.T) {
|
||||||
// TODO: eventually this will create the missing variant on demand
|
// TODO: eventually this will create the missing variant on demand
|
||||||
_, errs := testTransition(fmt.Sprintf(testTransitionBp,
|
_, errs := testTransition(fmt.Sprintf(testTransitionBp,
|
||||||
`post_transition_deps: ["E:missing"],`))
|
`post_transition_deps: ["E:missing"],`, ""))
|
||||||
expectedError := `Android.bp:8:4: dependency "E" of "B" missing variant:
|
expectedError := `Android.bp:8:4: dependency "E" of "B" missing variant:
|
||||||
transition:missing
|
transition:missing
|
||||||
available variants:
|
available variants:
|
||||||
|
|
Loading…
Reference in a new issue