From d6ceb8600c062531db02e87f342629bcea837d3a Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 4 Mar 2021 23:02:31 +0000 Subject: [PATCH] Clean up cc.RegisterRequiredBuildComponentsForTest() Changes this function so it only registers components from the cc package by pushing the call to genrule.RegisterGenruleBuildComponents() down into those packages whose tests need it. This will make it easier to migrate cc package tests to test fixtures as the RegisterRequiredBuildComponentsForTest() no longer overlaps with preparers from the genrule packages. Bug: 181070625 Test: m nothing Change-Id: Ic00c7e480dc738d7a88d038aca6ab95a1502a24a --- cc/testing.go | 2 +- java/java_test.go | 3 +++ rust/testing.go | 2 ++ sdk/testing.go | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cc/testing.go b/cc/testing.go index 45e531208..f62c5f114 100644 --- a/cc/testing.go +++ b/cc/testing.go @@ -25,7 +25,6 @@ func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) { RegisterBinaryBuildComponents(ctx) RegisterLibraryBuildComponents(ctx) RegisterLibraryHeadersBuildComponents(ctx) - genrule.RegisterGenruleBuildComponents(ctx) ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory) ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory) @@ -591,6 +590,7 @@ func TestConfig(buildDir string, os android.OsType, env map[string]string, func CreateTestContext(config android.Config) *android.TestContext { ctx := android.NewTestArchContext(config) + genrule.RegisterGenruleBuildComponents(ctx) ctx.RegisterModuleType("cc_fuzz", FuzzFactory) ctx.RegisterModuleType("cc_test", TestFactory) ctx.RegisterModuleType("cc_test_library", TestLibraryFactory) diff --git a/java/java_test.go b/java/java_test.go index bb51ebc3d..911265532 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -25,6 +25,7 @@ import ( "strings" "testing" + "android/soong/genrule" "github.com/google/blueprint/proptools" "android/soong/android" @@ -79,6 +80,8 @@ func testContext(config android.Config) *android.TestContext { android.RegisterPrebuiltMutators(ctx) + genrule.RegisterGenruleBuildComponents(ctx) + // Register module types and mutators from cc needed for JNI testing cc.RegisterRequiredBuildComponentsForTest(ctx) diff --git a/rust/testing.go b/rust/testing.go index 1afe27ef0..9534ab580 100644 --- a/rust/testing.go +++ b/rust/testing.go @@ -17,6 +17,7 @@ package rust import ( "android/soong/android" "android/soong/cc" + "android/soong/genrule" ) func GatherRequiredDepsForTest() string { @@ -211,6 +212,7 @@ func CreateTestContext(config android.Config) *android.TestContext { ctx := android.NewTestArchContext(config) android.RegisterPrebuiltMutators(ctx) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) + genrule.RegisterGenruleBuildComponents(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx) RegisterRequiredBuildComponentsForTest(ctx) diff --git a/sdk/testing.go b/sdk/testing.go index 0bbf7f443..7a2540a27 100644 --- a/sdk/testing.go +++ b/sdk/testing.go @@ -26,6 +26,7 @@ import ( "android/soong/android" "android/soong/apex" "android/soong/cc" + "android/soong/genrule" "android/soong/java" ) @@ -109,6 +110,9 @@ func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsTy // from java package java.RegisterRequiredBuildComponentsForTest(ctx) + // from genrule package + genrule.RegisterGenruleBuildComponents(ctx) + // from cc package cc.RegisterRequiredBuildComponentsForTest(ctx)