Refactor factories

Change module factories from returning a blueprint.Module and a list
of property structs to returning an android.Module, which holds the
list of property structs.

Test: build.ninja identical except for Factory: comment lines
Change-Id: Ica1d823f009db812c518f271a386fbff39c9766f
diff --git a/python/binary.go b/python/binary.go
index 81e8bd9..ae2693b 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -21,8 +21,6 @@
 	"path/filepath"
 	"strings"
 
-	"github.com/google/blueprint"
-
 	"android/soong/android"
 )
 
@@ -74,15 +72,16 @@
 	stubTemplateHost = "build/soong/python/scripts/stub_template_host.txt"
 )
 
-func PythonBinaryHostFactory() (blueprint.Module, []interface{}) {
+func PythonBinaryHostFactory() android.Module {
 	decorator := &pythonBinaryHostDecorator{
 		pythonDecorator: pythonDecorator{baseInstaller: NewPythonInstaller("bin")}}
 
 	module := &PythonBinaryHost{}
 	module.pythonBaseModule.installer = decorator
+	module.AddProperties(&module.binaryProperties)
 
 	return InitPythonBaseModule(&module.pythonBinaryBase.pythonBaseModule,
-		&module.pythonBinaryBase, android.HostSupportedNoCross, &module.binaryProperties)
+		&module.pythonBinaryBase, android.HostSupportedNoCross)
 }
 
 func (p *pythonBinaryBase) GeneratePythonBuildActions(ctx android.ModuleContext) android.OptionalPath {
diff --git a/python/library.go b/python/library.go
index 0b70756..2039e56 100644
--- a/python/library.go
+++ b/python/library.go
@@ -17,8 +17,6 @@
 // This file contains the module types for building Python library.
 
 import (
-	"github.com/google/blueprint"
-
 	"android/soong/android"
 )
 
@@ -32,7 +30,7 @@
 
 var _ PythonSubModule = (*PythonLibrary)(nil)
 
-func PythonLibraryHostFactory() (blueprint.Module, []interface{}) {
+func PythonLibraryHostFactory() android.Module {
 	module := &PythonLibrary{}
 
 	return InitPythonBaseModule(&module.pythonBaseModule, module, android.HostSupportedNoCross)
diff --git a/python/python.go b/python/python.go
index ab80e4d..df5999d 100644
--- a/python/python.go
+++ b/python/python.go
@@ -152,14 +152,15 @@
 var _ android.AndroidMkDataProvider = (*pythonBaseModule)(nil)
 
 func InitPythonBaseModule(baseModule *pythonBaseModule, subModule PythonSubModule,
-	hod android.HostOrDeviceSupported,
-	props ...interface{}) (blueprint.Module, []interface{}) {
+	hod android.HostOrDeviceSupported) android.Module {
 
 	baseModule.subModule = subModule
 
-	props = append(props, &baseModule.properties)
+	baseModule.AddProperties(&baseModule.properties)
 
-	return android.InitAndroidArchModule(baseModule, hod, android.MultilibCommon, props...)
+	android.InitAndroidArchModule(baseModule, hod, android.MultilibCommon)
+
+	return baseModule
 }
 
 // the tag used to mark dependencies within "py_libs" attribute.
diff --git a/python/python_test.go b/python/python_test.go
index bb407e4..57aaa34 100644
--- a/python/python_test.go
+++ b/python/python_test.go
@@ -313,8 +313,10 @@
 		t.Run(d.desc, func(t *testing.T) {
 			ctx := blueprint.NewContext()
 			android.RegisterTestMutators(ctx)
-			ctx.RegisterModuleType("python_library_host", PythonLibraryHostFactory)
-			ctx.RegisterModuleType("python_binary_host", PythonBinaryHostFactory)
+			ctx.RegisterModuleType("python_library_host",
+				android.ModuleFactoryAdaptor(PythonLibraryHostFactory))
+			ctx.RegisterModuleType("python_binary_host",
+				android.ModuleFactoryAdaptor(PythonBinaryHostFactory))
 			ctx.MockFileSystem(d.mockFiles)
 			_, testErrs := ctx.ParseBlueprintsFiles(bpFile)
 			fail(t, testErrs)
diff --git a/python/test.go b/python/test.go
index 8318438..837eb25 100644
--- a/python/test.go
+++ b/python/test.go
@@ -17,8 +17,6 @@
 import (
 	"android/soong/android"
 	"path/filepath"
-
-	"github.com/google/blueprint"
 )
 
 // This file contains the module types for building Python test.
@@ -42,13 +40,15 @@
 	p.pythonDecorator.baseInstaller.install(ctx, file)
 }
 
-func PythonTestHostFactory() (blueprint.Module, []interface{}) {
+func PythonTestHostFactory() android.Module {
 	decorator := &pythonTestHostDecorator{
 		pythonDecorator: pythonDecorator{baseInstaller: NewPythonInstaller("nativetest")}}
 
 	module := &PythonBinaryHost{}
 	module.pythonBaseModule.installer = decorator
 
+	module.AddProperties(&module.binaryProperties)
+
 	return InitPythonBaseModule(&module.pythonBinaryBase.pythonBaseModule,
-		&module.pythonBinaryBase, android.HostSupportedNoCross, &module.binaryProperties)
+		&module.pythonBinaryBase, android.HostSupportedNoCross)
 }