diff options
author | Colin Cross <ccross@android.com> | 2019-04-16 14:43:28 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2019-04-16 21:46:28 +0000 |
commit | f8b860a0fb98448dd44db835d5f146e8a50e5ef5 (patch) | |
tree | dd9e592e116916035dcfc5b84552a5ffef5139cf /android | |
parent | 819635624843ae286cefae6a9a89d3d90ed61cd8 (diff) | |
download | soong-f8b860a0fb98448dd44db835d5f146e8a50e5ef5.tar.gz |
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
Diffstat (limited to 'android')
-rw-r--r-- | android/hooks.go | 4 | ||||
-rw-r--r-- | android/mutator.go | 4 | ||||
-rw-r--r-- | android/testing.go | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/android/hooks.go b/android/hooks.go index 6b2468dc5..d55678e9d 100644 --- a/android/hooks.go +++ b/android/hooks.go @@ -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 diff --git a/android/mutator.go b/android/mutator.go index 71237a1cd..5ce743a8f 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -73,9 +73,7 @@ type RegisterMutatorsContext interface { type RegisterMutatorFunc func(RegisterMutatorsContext) var preArch = []RegisterMutatorFunc{ - func(ctx RegisterMutatorsContext) { - ctx.TopDown("load_hooks", LoadHookMutator).Parallel() - }, + registerLoadHookMutator, RegisterNamespaceMutator, RegisterPrebuiltsPreArchMutators, RegisterDefaultsPreArchMutators, diff --git a/android/testing.go b/android/testing.go index 0ec5af58a..aee68550b 100644 --- a/android/testing.go +++ b/android/testing.go @@ -37,6 +37,8 @@ func NewTestContext() *TestContext { ctx.SetNameInterface(nameResolver) + ctx.preArch = append(ctx.preArch, registerLoadHookMutator) + ctx.postDeps = append(ctx.postDeps, registerPathDepsMutator) return ctx |