Use alias for test_per_src apex dependencies

AddFarVariationDependencies was broken, which allowed apex to add
dependencies on tests by requesting an empty test_per_src variation
even though some test dependencies did not have a test_per_src
variation.  Add an alias from the pre-test_per_src variation
variant to the empty test_per_src variation, and drop the
test_per_src variation when requesting the depencency.

Test: TestApexWithTests
Change-Id: I2ed7bdd761027956141e25d4d81f9074afe628b6
This commit is contained in:
Colin Cross 2020-08-21 15:55:50 -07:00
parent c2c2d4e716
commit 90dab3498d
2 changed files with 2 additions and 5 deletions

View file

@ -1450,8 +1450,6 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
binVariations := target.Variations()
libVariations := append(target.Variations(),
blueprint.Variation{Mutator: "link", Variation: "shared"})
testVariations := append(target.Variations(),
blueprint.Variation{Mutator: "test_per_src", Variation: ""}) // "" is the all-tests variant
if ctx.Device() {
binVariations = append(binVariations,
@ -1459,8 +1457,6 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
libVariations = append(libVariations,
blueprint.Variation{Mutator: "image", Variation: imageVariation},
blueprint.Variation{Mutator: "version", Variation: ""}) // "" is the non-stub variant
testVariations = append(testVariations,
blueprint.Variation{Mutator: "image", Variation: imageVariation})
}
ctx.AddFarVariationDependencies(libVariations, sharedLibTag, nativeModules.Native_shared_libs...)
@ -1469,7 +1465,7 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
ctx.AddFarVariationDependencies(binVariations, executableTag, nativeModules.Binaries...)
ctx.AddFarVariationDependencies(testVariations, testTag, nativeModules.Tests...)
ctx.AddFarVariationDependencies(binVariations, testTag, nativeModules.Tests...)
}
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {

View file

@ -223,6 +223,7 @@ func TestPerSrcMutator(mctx android.BottomUpMutatorContext) {
tests[i].(*Module).linker.(testPerSrc).setSrc(testNames[i], src)
mctx.AddInterVariantDependency(testPerSrcDepTag, all_tests, tests[i])
}
mctx.AliasVariation("")
}
}
}