summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2019-12-18 19:51:55 +0000
committerPaul Duffin <paulduffin@google.com>2019-12-19 10:09:53 +0000
commitf9b1da0fcb4b76b04c96a355bec7845cdf87ba7e (patch)
treedb7a446bc9841f4ff9d6183a1598e24e16c89d02 /java/java_test.go
parentb4cc0206bb384f0e802c9ef21966686a6d3d30ee (diff)
Dedup registration code for module types and singletons
The registration of module types and singletons is duplicated between init() functions that register them for use in the build runtime and test context creation code that registers them for testing. This is a proof of concept for a mechanism that will allow the code to be shared. It defines a RegistrationContext interface that is implemented by both the TestContext and the new initRegistrationContext type. An instance of the the latter is available through the InitRegistrationContext variable. The intent is that the registration of the module types and singleton types will be extracted from the init() function into a separate function that takes a RegistrationContext parameter. That method is called from init() passing in the InitRegistrationContext and from a test passing in the TestContext. Something like this: func init() { RegisterBuildComponents(android.InitRegistrationContext) } func RegisterBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType(....) .... } A test would do something like this: ctx := android.NewTestContext() RegisterBuildComponents(ctx) Test: m nothing Change-Id: I97173cabb6d6cf7ce98fdb5f73418438b1997b35
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go23
1 files changed, 3 insertions, 20 deletions
diff --git a/java/java_test.go b/java/java_test.go
index 49838c7c7..32527365c 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -63,27 +63,12 @@ func testConfig(env map[string]string, bp string, fs map[string][]byte) android.
func testContext() *android.TestContext {
ctx := android.NewTestArchContext()
- ctx.RegisterModuleType("android_app", AndroidAppFactory)
- ctx.RegisterModuleType("android_app_certificate", AndroidAppCertificateFactory)
- ctx.RegisterModuleType("android_app_import", AndroidAppImportFactory)
- ctx.RegisterModuleType("android_library", AndroidLibraryFactory)
- ctx.RegisterModuleType("android_test", AndroidTestFactory)
- ctx.RegisterModuleType("android_test_helper_app", AndroidTestHelperAppFactory)
- ctx.RegisterModuleType("android_test_import", AndroidTestImportFactory)
- ctx.RegisterModuleType("java_binary", BinaryFactory)
- ctx.RegisterModuleType("java_binary_host", BinaryHostFactory)
- ctx.RegisterModuleType("java_device_for_host", DeviceForHostFactory)
- ctx.RegisterModuleType("java_host_for_device", HostForDeviceFactory)
- ctx.RegisterModuleType("java_library", LibraryFactory)
- ctx.RegisterModuleType("java_library_host", LibraryHostFactory)
- ctx.RegisterModuleType("java_test", TestFactory)
- ctx.RegisterModuleType("java_import", ImportFactory)
- ctx.RegisterModuleType("java_import_host", ImportFactoryHost)
- ctx.RegisterModuleType("java_defaults", DefaultsFactory)
+ RegisterJavaBuildComponents(ctx)
+ RegisterAppBuildComponents(ctx)
+ RegisterAARBuildComponents(ctx)
ctx.RegisterModuleType("java_system_modules", SystemModulesFactory)
ctx.RegisterModuleType("java_genrule", genRuleFactory)
ctx.RegisterModuleType("java_plugin", PluginFactory)
- ctx.RegisterModuleType("dex_import", DexImportFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
ctx.RegisterModuleType("droiddoc", DroiddocFactory)
@@ -92,8 +77,6 @@ func testContext() *android.TestContext {
ctx.RegisterModuleType("prebuilt_stubs_sources", PrebuiltStubsSourcesFactory)
ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory)
ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
- ctx.RegisterModuleType("override_android_app", OverrideAndroidAppModuleFactory)
- ctx.RegisterModuleType("override_android_test", OverrideAndroidTestModuleFactory)
ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)