From 84dfc3d33138470a9fbf624eaeda977b9f48e571 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 25 Sep 2019 11:33:01 -0700 Subject: [PATCH] Make CreateModule take an android.ModuleFactory Reduce the boilerplate required to call CreateModule by taking an android.ModuleFactory instead of a blueprint.ModuleFactory. Test: m checkbuild Change-Id: I1259d2dd3f7893b5319c333bc180727ac40f9e91 --- android/hooks.go | 2 +- android/mutator.go | 6 +++--- java/prebuilt_apis.go | 4 ++-- java/sdk_library.go | 10 +++++----- sysprop/sysprop_library.go | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/android/hooks.go b/android/hooks.go index 58109961b..64ffd5250 100644 --- a/android/hooks.go +++ b/android/hooks.go @@ -30,7 +30,7 @@ type LoadHookContext interface { BaseModuleContext AppendProperties(...interface{}) PrependProperties(...interface{}) - CreateModule(blueprint.ModuleFactory, ...interface{}) + CreateModule(ModuleFactory, ...interface{}) } // Arch hooks are run after the module has been split into architecture variants, and can be used diff --git a/android/mutator.go b/android/mutator.go index e76f847c9..7b7859ce9 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -121,7 +121,7 @@ type TopDownMutatorContext interface { Rename(name string) - CreateModule(blueprint.ModuleFactory, ...interface{}) + CreateModule(ModuleFactory, ...interface{}) } type topDownMutatorContext struct { @@ -243,9 +243,9 @@ func (t *topDownMutatorContext) Rename(name string) { t.Module().base().commonProperties.DebugName = name } -func (t *topDownMutatorContext) CreateModule(factory blueprint.ModuleFactory, props ...interface{}) { +func (t *topDownMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) { inherited := []interface{}{&t.Module().base().commonProperties, &t.Module().base().variableProperties} - t.bp.CreateModule(factory, append(inherited, props...)...) + t.bp.CreateModule(ModuleFactoryAdaptor(factory), append(inherited, props...)...) } func (b *bottomUpMutatorContext) MutatorName() string { diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go index c37081130..0d5e31f69 100644 --- a/java/prebuilt_apis.go +++ b/java/prebuilt_apis.go @@ -82,7 +82,7 @@ func createImport(mctx android.TopDownMutatorContext, module string, scope strin props.Sdk_version = proptools.StringPtr("current") props.Installable = proptools.BoolPtr(false) - mctx.CreateModule(android.ModuleFactoryAdaptor(ImportFactory), &props) + mctx.CreateModule(ImportFactory, &props) } func createFilegroup(mctx android.TopDownMutatorContext, module string, scope string, apiver string, path string) { @@ -93,7 +93,7 @@ func createFilegroup(mctx android.TopDownMutatorContext, module string, scope st }{} filegroupProps.Name = proptools.StringPtr(fgName) filegroupProps.Srcs = []string{path} - mctx.CreateModule(android.ModuleFactoryAdaptor(android.FileGroupFactory), &filegroupProps) + mctx.CreateModule(android.FileGroupFactory, &filegroupProps) } func getPrebuiltFiles(mctx android.TopDownMutatorContext, name string) []string { diff --git a/java/sdk_library.go b/java/sdk_library.go index 30fd1c4e2..cc7256b1b 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -422,7 +422,7 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiSc props.Product_specific = proptools.BoolPtr(true) } - mctx.CreateModule(android.ModuleFactoryAdaptor(LibraryFactory), &props) + mctx.CreateModule(LibraryFactory, &props) } // Creates a droiddoc module that creates stubs source files from the given full source @@ -522,7 +522,7 @@ func (module *SdkLibrary) createDocs(mctx android.LoadHookContext, apiScope apiS module.latestRemovedApiFilegroupName(apiScope)) props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true) - mctx.CreateModule(android.ModuleFactoryAdaptor(DroidstubsFactory), &props) + mctx.CreateModule(DroidstubsFactory, &props) } // Creates the xml file that publicizes the runtime library @@ -560,7 +560,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) { genruleProps.Name = proptools.StringPtr(module.xmlFileName() + "-gen") genruleProps.Cmd = proptools.StringPtr("echo '" + xmlContent + "' > $(out)") genruleProps.Out = []string{module.xmlFileName()} - mctx.CreateModule(android.ModuleFactoryAdaptor(genrule.GenRuleFactory), &genruleProps) + mctx.CreateModule(genrule.GenRuleFactory, &genruleProps) // creates a prebuilt_etc module to actually place the xml file under // /etc/permissions @@ -582,7 +582,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) { } else if module.ProductSpecific() { etcProps.Product_specific = proptools.BoolPtr(true) } - mctx.CreateModule(android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory), &etcProps) + mctx.CreateModule(android.PrebuiltEtcFactory, &etcProps) } func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { @@ -815,7 +815,7 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte props.Product_specific = proptools.BoolPtr(true) } - mctx.CreateModule(android.ModuleFactoryAdaptor(ImportFactory), &props, &module.properties) + mctx.CreateModule(ImportFactory, &props, &module.properties) javaSdkLibraries := javaSdkLibraries(mctx.Config()) javaSdkLibrariesLock.Lock() diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go index 5eb7fa9ac..a87634182 100644 --- a/sysprop/sysprop_library.go +++ b/sysprop/sysprop_library.go @@ -362,7 +362,7 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { ccProps.Recovery_available = m.properties.Recovery_available ccProps.Vendor_available = m.properties.Vendor_available - ctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProps) + ctx.CreateModule(cc.LibraryFactory, &ccProps) // internal scope contains all properties // public scope only contains public properties @@ -390,7 +390,7 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { Name: proptools.StringPtr(m.javaGenModuleName()), } - ctx.CreateModule(android.ModuleFactoryAdaptor(syspropJavaGenFactory), &javaGenProps) + ctx.CreateModule(syspropJavaGenFactory, &javaGenProps) javaProps := struct { Name *string @@ -413,7 +413,7 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { javaProps.Sdk_version = proptools.StringPtr("core_current") javaProps.Libs = []string{stub} - ctx.CreateModule(android.ModuleFactoryAdaptor(java.LibraryFactory), &javaProps) + ctx.CreateModule(java.LibraryFactory, &javaProps) } func syspropDepsMutator(ctx android.BottomUpMutatorContext) {