Use LoadHook to create modules in java_sdk_library

Creating new modules in a mutator is dangerous, as other mutators
that need to see the new modules may already have run, in this case
the prebuilts mutator.  Move SdkLibraryMutator to a LoadHook instead.
Also moves registering the LoadHook mutator to testing.go so it is
registered for all tests.

Test: m checkbuild
Change-Id: I08bd76a0e6205d2ca27861058067a1562c339eed
This commit is contained in:
Colin Cross
2019-04-16 14:43:28 -07:00
parent 8196356248
commit f8b860a0fb
7 changed files with 14 additions and 33 deletions

View File

@@ -123,6 +123,10 @@ type hooks struct {
install []func(InstallHookContext)
}
func registerLoadHookMutator(ctx RegisterMutatorsContext) {
ctx.TopDown("load_hooks", LoadHookMutator).Parallel()
}
func LoadHookMutator(ctx TopDownMutatorContext) {
if m, ok := ctx.Module().(Module); ok {
// Cast through *androidTopDownMutatorContext because AppendProperties is implemented