Dedup droiddoc module type registration

Some tests were changed as they were using the wrong name for the
droiddoc_exported_dir module type.

Test: m checkbuild
Bug: 146540677
Change-Id: If57404760d2df3757c93e237696359355cf0c96e
This commit is contained in:
Paul Duffin
2019-12-19 10:21:09 +00:00
parent f3273c5587
commit 884363e782
3 changed files with 27 additions and 22 deletions

View File

@@ -27,19 +27,8 @@ import (
)
func init() {
android.RegisterModuleType("doc_defaults", DocDefaultsFactory)
android.RegisterModuleType("stubs_defaults", StubsDefaultsFactory)
android.RegisterModuleType("droiddoc", DroiddocFactory)
android.RegisterModuleType("droiddoc_host", DroiddocHostFactory)
android.RegisterModuleType("droiddoc_exported_dir", ExportedDroiddocDirFactory)
android.RegisterModuleType("javadoc", JavadocFactory)
android.RegisterModuleType("javadoc_host", JavadocHostFactory)
android.RegisterModuleType("droidstubs", DroidstubsFactory)
android.RegisterModuleType("droidstubs_host", DroidstubsHostFactory)
android.RegisterModuleType("prebuilt_stubs_sources", PrebuiltStubsSourcesFactory)
RegisterDocsBuildComponents(android.InitRegistrationContext)
RegisterStubsBuildComponents(android.InitRegistrationContext)
// Register sdk member type.
android.RegisterSdkMemberType(&droidStubsSdkMemberType{
@@ -49,6 +38,25 @@ func init() {
})
}
func RegisterDocsBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("doc_defaults", DocDefaultsFactory)
ctx.RegisterModuleType("droiddoc", DroiddocFactory)
ctx.RegisterModuleType("droiddoc_host", DroiddocHostFactory)
ctx.RegisterModuleType("droiddoc_exported_dir", ExportedDroiddocDirFactory)
ctx.RegisterModuleType("javadoc", JavadocFactory)
ctx.RegisterModuleType("javadoc_host", JavadocHostFactory)
}
func RegisterStubsBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("stubs_defaults", StubsDefaultsFactory)
ctx.RegisterModuleType("droidstubs", DroidstubsFactory)
ctx.RegisterModuleType("droidstubs_host", DroidstubsHostFactory)
ctx.RegisterModuleType("prebuilt_stubs_sources", PrebuiltStubsSourcesFactory)
}
var (
srcsLibTag = dependencyTag{name: "sources from javalib"}
)
@@ -782,7 +790,7 @@ func (d *Droiddoc) doclavaDocsFlags(ctx android.ModuleContext, cmd *android.Rule
if t, ok := m.(*ExportedDroiddocDir); ok {
cmd.FlagWithArg("-templatedir ", t.dir.String()).Implicits(t.deps)
} else {
ctx.PropertyErrorf("custom_template", "module %q is not a droiddoc_template", ctx.OtherModuleName(m))
ctx.PropertyErrorf("custom_template", "module %q is not a droiddoc_exported_dir", ctx.OtherModuleName(m))
}
})

View File

@@ -71,10 +71,8 @@ func testContext() *android.TestContext {
ctx.RegisterModuleType("java_plugin", PluginFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
ctx.RegisterModuleType("droiddoc", DroiddocFactory)
ctx.RegisterModuleType("droiddoc_host", DroiddocHostFactory)
ctx.RegisterModuleType("droiddoc_template", ExportedDroiddocDirFactory)
ctx.RegisterModuleType("prebuilt_stubs_sources", PrebuiltStubsSourcesFactory)
RegisterDocsBuildComponents(ctx)
RegisterStubsBuildComponents(ctx)
ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory)
ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
@@ -875,7 +873,7 @@ func TestSharding(t *testing.T) {
func TestDroiddoc(t *testing.T) {
ctx, _ := testJava(t, `
droiddoc_template {
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
path: ".",
}
@@ -1021,7 +1019,7 @@ func TestJavaLibrary(t *testing.T) {
func TestJavaSdkLibrary(t *testing.T) {
ctx, _ := testJava(t, `
droiddoc_template {
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
path: ".",
}

View File

@@ -80,8 +80,7 @@ func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, andr
// from java package
java.RegisterJavaBuildComponents(ctx)
java.RegisterAppBuildComponents(ctx)
ctx.RegisterModuleType("droidstubs", java.DroidstubsFactory)
ctx.RegisterModuleType("prebuilt_stubs_sources", java.PrebuiltStubsSourcesFactory)
java.RegisterStubsBuildComponents(ctx)
// from cc package
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)