diff --git a/android/config.go b/android/config.go index 4f35114a3..f30a708c6 100644 --- a/android/config.go +++ b/android/config.go @@ -185,6 +185,25 @@ func TestConfig(buildDir string) Config { return Config{config} } +// TestConfig returns a Config object suitable for using for tests that need to run the arch mutator +func TestArchConfig(buildDir string) Config { + testConfig := TestConfig(buildDir) + config := testConfig.config + + config.Targets = map[OsClass][]Target{ + Device: []Target{ + {Android, Arch{ArchType: Arm64, Native: true}}, + {Android, Arch{ArchType: Arm, Native: true}}, + }, + Host: []Target{ + {BuildOs, Arch{ArchType: X86_64}}, + {BuildOs, Arch{ArchType: X86}}, + }, + } + + return testConfig +} + // New creates a new Config object. The srcDir argument specifies the path to // the root source directory. It also loads the config file, if found. func NewConfig(srcDir, buildDir string) (Config, error) { diff --git a/android/mutator.go b/android/mutator.go index e20bc2ce2..04407eb32 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -78,11 +78,13 @@ var preArch = []RegisterMutatorFunc{ RegisterDefaultsPreArchMutators, } +func registerArchMutator(ctx RegisterMutatorsContext) { + ctx.BottomUp("arch", archMutator).Parallel() + ctx.TopDown("arch_hooks", archHookMutator).Parallel() +} + var preDeps = []RegisterMutatorFunc{ - func(ctx RegisterMutatorsContext) { - ctx.BottomUp("arch", archMutator).Parallel() - ctx.TopDown("arch_hooks", archHookMutator).Parallel() - }, + registerArchMutator, } var postDeps = []RegisterMutatorFunc{ diff --git a/android/testing.go b/android/testing.go index 414477510..519e27997 100644 --- a/android/testing.go +++ b/android/testing.go @@ -27,6 +27,12 @@ func NewTestContext() *TestContext { } } +func NewTestArchContext() *TestContext { + ctx := NewTestContext() + ctx.preDeps = append(ctx.preDeps, registerArchMutator) + return ctx +} + type TestContext struct { *blueprint.Context preArch, preDeps, postDeps []RegisterMutatorFunc