Merge "Add java.RegisterRequiredBuildComponentsForTest function"

This commit is contained in:
Paul Duffin
2021-01-22 17:41:02 +00:00
committed by Gerrit Code Review
6 changed files with 29 additions and 37 deletions

View File

@@ -248,6 +248,7 @@ func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*andr
cc.RegisterRequiredBuildComponentsForTest(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx)
rust.RegisterRequiredBuildComponentsForTest(ctx) rust.RegisterRequiredBuildComponentsForTest(ctx)
java.RegisterRequiredBuildComponentsForTest(ctx)
ctx.RegisterModuleType("cc_test", cc.TestFactory) ctx.RegisterModuleType("cc_test", cc.TestFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory) ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
@@ -256,14 +257,6 @@ func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*andr
ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory) ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory)
ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory) ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
java.RegisterJavaBuildComponents(ctx)
java.RegisterSystemModulesBuildComponents(ctx)
java.RegisterAppBuildComponents(ctx)
java.RegisterAppImportBuildComponents(ctx)
java.RegisterAppSetBuildComponents(ctx)
java.RegisterRuntimeResourceOverlayBuildComponents(ctx)
java.RegisterSdkLibraryBuildComponents(ctx)
java.RegisterPrebuiltApisBuildComponents(ctx)
ctx.RegisterSingletonType("apex_keys_text", apexKeysTextFactory) ctx.RegisterSingletonType("apex_keys_text", apexKeysTextFactory)
ctx.RegisterModuleType("bpf", bpf.BpfFactory) ctx.RegisterModuleType("bpf", bpf.BpfFactory)
@@ -5957,10 +5950,7 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
android.RegisterPrebuiltMutators(ctx) android.RegisterPrebuiltMutators(ctx)
cc.RegisterRequiredBuildComponentsForTest(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx)
java.RegisterJavaBuildComponents(ctx) java.RegisterRequiredBuildComponentsForTest(ctx)
java.RegisterSystemModulesBuildComponents(ctx)
java.RegisterAppBuildComponents(ctx)
java.RegisterDexpreoptBootJarsComponents(ctx)
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators) ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
ctx.PreDepsMutators(RegisterPreDepsMutators) ctx.PreDepsMutators(RegisterPreDepsMutators)
ctx.PostDepsMutators(RegisterPostDepsMutators) ctx.PostDepsMutators(RegisterPostDepsMutators)
@@ -6164,9 +6154,7 @@ func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, apexBootJar
ctx.RegisterModuleType("apex_key", ApexKeyFactory) ctx.RegisterModuleType("apex_key", ApexKeyFactory)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
cc.RegisterRequiredBuildComponentsForTest(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx)
java.RegisterJavaBuildComponents(ctx) java.RegisterRequiredBuildComponentsForTest(ctx)
java.RegisterSystemModulesBuildComponents(ctx)
java.RegisterDexpreoptBootJarsComponents(ctx)
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators) ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
ctx.PreDepsMutators(RegisterPreDepsMutators) ctx.PreDepsMutators(RegisterPreDepsMutators)
ctx.PostDepsMutators(RegisterPostDepsMutators) ctx.PostDepsMutators(RegisterPostDepsMutators)

View File

@@ -52,7 +52,6 @@ func testDexpreoptBoot(t *testing.T, ruleFile string, expectedInputs, expectedOu
dexpreopt.SetTestGlobalConfig(config, dexpreoptConfig) dexpreopt.SetTestGlobalConfig(config, dexpreoptConfig)
ctx := testContext(config) ctx := testContext(config)
RegisterDexpreoptBootJarsComponents(ctx)
run(t, ctx, config) run(t, ctx, config)
dexpreoptBootJars := ctx.SingletonForTests("dex_bootjars") dexpreoptBootJars := ctx.SingletonForTests("dex_bootjars")

View File

@@ -73,21 +73,10 @@ func testConfig(env map[string]string, bp string, fs map[string][]byte) android.
func testContext(config android.Config) *android.TestContext { func testContext(config android.Config) *android.TestContext {
ctx := android.NewTestArchContext(config) ctx := android.NewTestArchContext(config)
RegisterJavaBuildComponents(ctx) RegisterRequiredBuildComponentsForTest(ctx)
RegisterAppBuildComponents(ctx)
RegisterAppImportBuildComponents(ctx)
RegisterAppSetBuildComponents(ctx)
RegisterAARBuildComponents(ctx)
RegisterGenRuleBuildComponents(ctx)
RegisterRuntimeResourceOverlayBuildComponents(ctx)
RegisterSystemModulesBuildComponents(ctx)
ctx.RegisterModuleType("java_plugin", PluginFactory) ctx.RegisterModuleType("java_plugin", PluginFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("python_binary_host", python.PythonBinaryHostFactory) ctx.RegisterModuleType("python_binary_host", python.PythonBinaryHostFactory)
RegisterDocsBuildComponents(ctx)
RegisterStubsBuildComponents(ctx)
RegisterPrebuiltApisBuildComponents(ctx)
RegisterSdkLibraryBuildComponents(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.PreArchMutators(android.RegisterComponentsMutator) ctx.PreArchMutators(android.RegisterComponentsMutator)

View File

@@ -95,6 +95,29 @@ func prebuiltApisFilesForLibs(apiLevels []string, sdkLibs []string) map[string][
return fs return fs
} }
// Register build components provided by this package that are needed by tests.
//
// In particular this must register all the components that are used in the `Android.bp` snippet
// returned by GatherRequiredDepsForTest()
func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
RegisterAARBuildComponents(ctx)
RegisterAppBuildComponents(ctx)
RegisterAppImportBuildComponents(ctx)
RegisterAppSetBuildComponents(ctx)
RegisterDexpreoptBootJarsComponents(ctx)
RegisterDocsBuildComponents(ctx)
RegisterGenRuleBuildComponents(ctx)
RegisterJavaBuildComponents(ctx)
RegisterPrebuiltApisBuildComponents(ctx)
RegisterRuntimeResourceOverlayBuildComponents(ctx)
RegisterSdkLibraryBuildComponents(ctx)
RegisterStubsBuildComponents(ctx)
RegisterSystemModulesBuildComponents(ctx)
}
// Gather the module definitions needed by tests that depend upon code from this package.
//
// Returns an `Android.bp` snippet that defines the modules that are needed by this package.
func GatherRequiredDepsForTest() string { func GatherRequiredDepsForTest() string {
var bp string var bp string

View File

@@ -107,12 +107,7 @@ func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsTy
ctx.PostDepsMutators(android.RegisterVisibilityRuleEnforcer) ctx.PostDepsMutators(android.RegisterVisibilityRuleEnforcer)
// from java package // from java package
java.RegisterJavaBuildComponents(ctx) java.RegisterRequiredBuildComponentsForTest(ctx)
java.RegisterAppBuildComponents(ctx)
java.RegisterSdkLibraryBuildComponents(ctx)
java.RegisterPrebuiltApisBuildComponents(ctx)
java.RegisterStubsBuildComponents(ctx)
java.RegisterSystemModulesBuildComponents(ctx)
// from cc package // from cc package
cc.RegisterRequiredBuildComponentsForTest(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx)

View File

@@ -58,9 +58,7 @@ func TestMain(m *testing.M) {
func testContext(config android.Config) *android.TestContext { func testContext(config android.Config) *android.TestContext {
ctx := android.NewTestArchContext(config) ctx := android.NewTestArchContext(config)
java.RegisterJavaBuildComponents(ctx) java.RegisterRequiredBuildComponentsForTest(ctx)
java.RegisterAppBuildComponents(ctx)
java.RegisterSystemModulesBuildComponents(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) { ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {