aboutsummaryrefslogtreecommitdiffstats
path: root/android/module.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-06-23 15:06:31 -0700
committerColin Cross <ccross@android.com>2017-06-30 21:08:36 +0000
commit36242850fdad11b4e6fbe061ef30f62e7e8c08d8 (patch)
treea3ca380533afd39e733c658560f87effb1ee0a46 /android/module.go
parent48173891485a22c9cab0e48f90a3a23be212f44a (diff)
downloadbuild_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 'android/module.go')
-rw-r--r--android/module.go39
1 files changed, 24 insertions, 15 deletions
diff --git a/android/module.go b/android/module.go
index 8f8f34b3..18810fb8 100644
--- a/android/module.go
+++ b/android/module.go
@@ -108,6 +108,9 @@ type Module interface {
InstallInData() bool
InstallInSanitizerDir() bool
SkipInstall()
+
+ AddProperties(props ...interface{})
+ GetProperties() []interface{}
}
type nameProperties struct {
@@ -194,24 +197,18 @@ const (
NeitherHostNorDeviceSupported
)
-func InitAndroidModule(m Module,
- propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
-
+func InitAndroidModule(m Module) {
base := m.base()
base.module = m
- propertyStructs = append(propertyStructs,
+ m.AddProperties(
&base.nameProperties,
&base.commonProperties,
&base.variableProperties)
-
- return m, propertyStructs
}
-func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib,
- propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
-
- _, propertyStructs = InitAndroidModule(m, propertyStructs...)
+func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
+ InitAndroidModule(m)
base := m.base()
base.commonProperties.HostOrDeviceSupported = hod
@@ -225,10 +222,10 @@ func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib
base.hostAndDeviceProperties.Device_supported = boolPtr(true)
fallthrough
case HostAndDeviceDefault:
- propertyStructs = append(propertyStructs, &base.hostAndDeviceProperties)
+ m.AddProperties(&base.hostAndDeviceProperties)
}
- return InitArchModule(m, propertyStructs...)
+ InitArchModule(m)
}
// A ModuleBase object contains the properties that are common to all Android
@@ -250,7 +247,6 @@ func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib
//
// import (
// "android/soong/android"
-// "github.com/google/blueprint"
// )
//
// type myModule struct {
@@ -260,9 +256,11 @@ func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib
// }
// }
//
-// func NewMyModule() (blueprint.Module, []interface{}) {
+// func NewMyModule() android.Module) {
// m := &myModule{}
-// return android.InitAndroidModule(m, &m.properties)
+// m.AddProperties(&m.properties)
+// android.InitAndroidModule(m)
+// return m
// }
//
// func (m *myModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -274,6 +272,7 @@ func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib
type ModuleBase struct {
// Putting the curiously recurring thing pointing to the thing that contains
// the thing pattern to good use.
+ // TODO: remove this
module Module
nameProperties nameProperties
@@ -295,6 +294,16 @@ type ModuleBase struct {
blueprintDir string
hooks hooks
+
+ registerProps []interface{}
+}
+
+func (a *ModuleBase) AddProperties(props ...interface{}) {
+ a.registerProps = append(a.registerProps, props...)
+}
+
+func (a *ModuleBase) GetProperties() []interface{} {
+ return a.registerProps
}
// Name returns the name of the module. It may be overridden by individual module types, for