diff options
author | Colin Cross <ccross@android.com> | 2017-06-23 15:06:31 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-06-30 21:08:36 +0000 |
commit | 36242850fdad11b4e6fbe061ef30f62e7e8c08d8 (patch) | |
tree | a3ca380533afd39e733c658560f87effb1ee0a46 /python | |
parent | 48173891485a22c9cab0e48f90a3a23be212f44a (diff) | |
download | build_soong-36242850fdad11b4e6fbe061ef30f62e7e8c08d8.tar.gz build_soong-36242850fdad11b4e6fbe061ef30f62e7e8c08d8.tar.bz2 build_soong-36242850fdad11b4e6fbe061ef30f62e7e8c08d8.zip |
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
Diffstat (limited to 'python')
-rw-r--r-- | python/binary.go | 7 | ||||
-rw-r--r-- | python/library.go | 4 | ||||
-rw-r--r-- | python/python.go | 9 | ||||
-rw-r--r-- | python/python_test.go | 6 | ||||
-rw-r--r-- | python/test.go | 8 |
5 files changed, 17 insertions, 17 deletions
diff --git a/python/binary.go b/python/binary.go index 81e8bd94..ae2693b9 100644 --- a/python/binary.go +++ b/python/binary.go @@ -21,8 +21,6 @@ import ( "path/filepath" "strings" - "github.com/google/blueprint" - "android/soong/android" ) @@ -74,15 +72,16 @@ var ( 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 0b707566..2039e561 100644 --- a/python/library.go +++ b/python/library.go @@ -17,8 +17,6 @@ package python // This file contains the module types for building Python library. import ( - "github.com/google/blueprint" - "android/soong/android" ) @@ -32,7 +30,7 @@ type PythonLibrary struct { 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 ab80e4d2..df5999d8 100644 --- a/python/python.go +++ b/python/python.go @@ -152,14 +152,15 @@ var _ PythonDependency = (*pythonBaseModule)(nil) 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 bb407e46..57aaa344 100644 --- a/python/python_test.go +++ b/python/python_test.go @@ -313,8 +313,10 @@ func TestPythonModule(t *testing.T) { 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 83184383..837eb259 100644 --- a/python/test.go +++ b/python/test.go @@ -17,8 +17,6 @@ package python import ( "android/soong/android" "path/filepath" - - "github.com/google/blueprint" ) // This file contains the module types for building Python test. @@ -42,13 +40,15 @@ func (p *pythonTestHostDecorator) install(ctx android.ModuleContext, file androi 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) } |