aboutsummaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-06-30 22:54:46 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-30 22:54:46 +0000
commitc59a0042a1610bccaec991fd2558555ccf610751 (patch)
tree98c5328938a0649a118a5ca24cd90953434da1fa /cc
parent73de19749274f4644c2a29620bdd655ab78ca1a3 (diff)
parent36242850fdad11b4e6fbe061ef30f62e7e8c08d8 (diff)
downloadbuild_soong-c59a0042a1610bccaec991fd2558555ccf610751.tar.gz
build_soong-c59a0042a1610bccaec991fd2558555ccf610751.tar.bz2
build_soong-c59a0042a1610bccaec991fd2558555ccf610751.zip
Refactor factories
am: 36242850fd Change-Id: Ied58f93022523557a5d28edbcd79a76b8e2fb875
Diffstat (limited to 'cc')
-rw-r--r--cc/binary.go5
-rw-r--r--cc/cc.go37
-rw-r--r--cc/coverage.go1
-rw-r--r--cc/library.go12
-rw-r--r--cc/llndk_library.go19
-rw-r--r--cc/ndk_headers.go16
-rw-r--r--cc/ndk_library.go14
-rw-r--r--cc/ndk_prebuilt.go10
-rw-r--r--cc/object.go4
-rw-r--r--cc/prebuilt.go8
-rw-r--r--cc/sabi.go2
-rw-r--r--cc/test.go12
-rw-r--r--cc/test_data_test.go12
-rw-r--r--cc/toolchain_library.go3
14 files changed, 83 insertions, 72 deletions
diff --git a/cc/binary.go b/cc/binary.go
index e9823297..f6e62b71 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -17,7 +17,6 @@ package cc
import (
"path/filepath"
- "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -55,13 +54,13 @@ func init() {
}
// Module factory for binaries
-func binaryFactory() (blueprint.Module, []interface{}) {
+func binaryFactory() android.Module {
module, _ := NewBinary(android.HostAndDeviceSupported)
return module.Init()
}
// Module factory for host binaries
-func binaryHostFactory() (blueprint.Module, []interface{}) {
+func binaryHostFactory() android.Module {
module, _ := NewBinary(android.HostSupported)
return module.Init()
}
diff --git a/cc/cc.go b/cc/cc.go
index 867b1969..a3f4c1d2 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -304,36 +304,38 @@ type Module struct {
flags Flags
}
-func (c *Module) Init() (blueprint.Module, []interface{}) {
- props := []interface{}{&c.Properties, &c.unused}
+func (c *Module) Init() android.Module {
+ c.AddProperties(&c.Properties, &c.unused)
if c.compiler != nil {
- props = append(props, c.compiler.compilerProps()...)
+ c.AddProperties(c.compiler.compilerProps()...)
}
if c.linker != nil {
- props = append(props, c.linker.linkerProps()...)
+ c.AddProperties(c.linker.linkerProps()...)
}
if c.installer != nil {
- props = append(props, c.installer.installerProps()...)
+ c.AddProperties(c.installer.installerProps()...)
}
if c.stl != nil {
- props = append(props, c.stl.props()...)
+ c.AddProperties(c.stl.props()...)
}
if c.sanitize != nil {
- props = append(props, c.sanitize.props()...)
+ c.AddProperties(c.sanitize.props()...)
}
if c.coverage != nil {
- props = append(props, c.coverage.props()...)
+ c.AddProperties(c.coverage.props()...)
}
if c.sabi != nil {
- props = append(props, c.sabi.props()...)
+ c.AddProperties(c.sabi.props()...)
}
for _, feature := range c.features {
- props = append(props, feature.props()...)
+ c.AddProperties(feature.props()...)
}
- _, props = android.InitAndroidArchModule(c, c.hod, c.multilib, props...)
+ android.InitAndroidArchModule(c, c.hod, c.multilib)
- return android.InitDefaultableModule(c, c, props...)
+ android.InitDefaultableModule(c, c)
+
+ return c
}
// Returns true for dependency roots (binaries)
@@ -1108,14 +1110,15 @@ func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
}
-func defaultsFactory() (blueprint.Module, []interface{}) {
+func defaultsFactory() android.Module {
return DefaultsFactory()
}
-func DefaultsFactory(props ...interface{}) (blueprint.Module, []interface{}) {
+func DefaultsFactory(props ...interface{}) android.Module {
module := &Defaults{}
- props = append(props,
+ module.AddProperties(props...)
+ module.AddProperties(
&BaseProperties{},
&BaseCompilerProperties{},
&BaseLinkerProperties{},
@@ -1134,7 +1137,9 @@ func DefaultsFactory(props ...interface{}) (blueprint.Module, []interface{}) {
&SAbiProperties{},
)
- return android.InitDefaultsModule(module, module, props...)
+ android.InitDefaultsModule(module, module)
+
+ return module
}
const (
diff --git a/cc/coverage.go b/cc/coverage.go
index b1c87837..0b4188f7 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -16,6 +16,7 @@ package cc
import (
"android/soong/android"
+
"github.com/google/blueprint"
)
diff --git a/cc/library.go b/cc/library.go
index 01642213..c7c11426 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -108,41 +108,41 @@ func init() {
// Module factory for combined static + shared libraries, device by default but with possible host
// support
-func libraryFactory() (blueprint.Module, []interface{}) {
+func libraryFactory() android.Module {
module, _ := NewLibrary(android.HostAndDeviceSupported)
return module.Init()
}
// Module factory for static libraries
-func libraryStaticFactory() (blueprint.Module, []interface{}) {
+func libraryStaticFactory() android.Module {
module, library := NewLibrary(android.HostAndDeviceSupported)
library.BuildOnlyStatic()
return module.Init()
}
// Module factory for shared libraries
-func librarySharedFactory() (blueprint.Module, []interface{}) {
+func librarySharedFactory() android.Module {
module, library := NewLibrary(android.HostAndDeviceSupported)
library.BuildOnlyShared()
return module.Init()
}
// Module factory for host static libraries
-func libraryHostStaticFactory() (blueprint.Module, []interface{}) {
+func libraryHostStaticFactory() android.Module {
module, library := NewLibrary(android.HostSupported)
library.BuildOnlyStatic()
return module.Init()
}
// Module factory for host shared libraries
-func libraryHostSharedFactory() (blueprint.Module, []interface{}) {
+func libraryHostSharedFactory() android.Module {
module, library := NewLibrary(android.HostSupported)
library.BuildOnlyShared()
return module.Init()
}
// Module factory for header-only libraries
-func libraryHeaderFactory() (blueprint.Module, []interface{}) {
+func libraryHeaderFactory() android.Module {
module, library := NewLibrary(android.HostAndDeviceSupported)
library.HeaderOnly()
return module.Init()
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index cde1bc79..66ffc9fe 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -18,8 +18,6 @@ import (
"path/filepath"
"strings"
- "github.com/google/blueprint"
-
"android/soong/android"
)
@@ -136,7 +134,7 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe
return stub.libraryDecorator.link(ctx, flags, deps, objs)
}
-func newLLndkStubLibrary() (*Module, []interface{}) {
+func newLLndkStubLibrary() *Module {
module, library := NewLibrary(android.DeviceSupported)
library.BuildOnlyShared()
module.stl = nil
@@ -150,13 +148,18 @@ func newLLndkStubLibrary() (*Module, []interface{}) {
module.linker = stub
module.installer = nil
- return module, []interface{}{&stub.Properties, &library.MutatedProperties, &library.flagExporter.Properties}
+ module.AddProperties(
+ &stub.Properties,
+ &library.MutatedProperties,
+ &library.flagExporter.Properties)
+
+ return module
}
-func llndkLibraryFactory() (blueprint.Module, []interface{}) {
- module, properties := newLLndkStubLibrary()
- return android.InitAndroidArchModule(module, android.DeviceSupported,
- android.MultilibBoth, properties...)
+func llndkLibraryFactory() android.Module {
+ module := newLLndkStubLibrary()
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
+ return module
}
func init() {
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 516f6e20..5fa32326 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -137,9 +137,11 @@ func (m *headerModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
}
-func ndkHeadersFactory() (blueprint.Module, []interface{}) {
+func ndkHeadersFactory() android.Module {
module := &headerModule{}
- return android.InitAndroidModule(module, &module.properties)
+ module.AddProperties(&module.properties)
+ android.InitAndroidModule(module)
+ return module
}
type preprocessedHeaderProperies struct {
@@ -251,12 +253,16 @@ func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir andro
return timestampFile
}
-func preprocessedNdkHeadersFactory() (blueprint.Module, []interface{}) {
+func preprocessedNdkHeadersFactory() android.Module {
module := &preprocessedHeaderModule{}
+
+ module.AddProperties(&module.properties)
+
// Host module rather than device module because device module install steps
// do not get run when embedded in make. We're not any of the existing
// module types that can be exposed via the Android.mk exporter, so just use
// a host module.
- return android.InitAndroidArchModule(module, android.HostSupportedNoCross,
- android.MultilibFirst, &module.properties)
+ android.InitAndroidArchModule(module, android.HostSupportedNoCross, android.MultilibFirst)
+
+ return module
}
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index d801775c..5765aa92 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -335,7 +335,7 @@ func (stub *stubDecorator) install(ctx ModuleContext, path android.Path) {
stub.installPath = ctx.InstallFile(installDir, path).String()
}
-func newStubLibrary() (*Module, []interface{}) {
+func newStubLibrary() *Module {
module, library := NewLibrary(android.DeviceSupported)
library.BuildOnlyShared()
module.stl = nil
@@ -349,11 +349,13 @@ func newStubLibrary() (*Module, []interface{}) {
module.linker = stub
module.installer = stub
- return module, []interface{}{&stub.properties, &library.MutatedProperties}
+ module.AddProperties(&stub.properties, &library.MutatedProperties)
+
+ return module
}
-func ndkLibraryFactory() (blueprint.Module, []interface{}) {
- module, properties := newStubLibrary()
- return android.InitAndroidArchModule(module, android.DeviceSupported,
- android.MultilibBoth, properties...)
+func ndkLibraryFactory() android.Module {
+ module := newStubLibrary()
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
+ return module
}
diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go
index 15a9d288..13424e3c 100644
--- a/cc/ndk_prebuilt.go
+++ b/cc/ndk_prebuilt.go
@@ -18,8 +18,6 @@ import (
"fmt"
"strings"
- "github.com/google/blueprint"
-
"android/soong/android"
"android/soong/cc/config"
)
@@ -67,7 +65,7 @@ func (*ndkPrebuiltObjectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
return deps
}
-func ndkPrebuiltObjectFactory() (blueprint.Module, []interface{}) {
+func ndkPrebuiltObjectFactory() android.Module {
module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
module.linker = &ndkPrebuiltObjectLinker{
objectLinker: objectLinker{
@@ -101,7 +99,7 @@ func (*ndkPrebuiltLibraryLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
return deps
}
-func ndkPrebuiltLibraryFactory() (blueprint.Module, []interface{}) {
+func ndkPrebuiltLibraryFactory() android.Module {
module, library := NewLibrary(android.DeviceSupported)
library.BuildOnlyShared()
linker := &ndkPrebuiltLibraryLinker{
@@ -132,7 +130,7 @@ type ndkPrebuiltStlLinker struct {
ndkPrebuiltLibraryLinker
}
-func ndkPrebuiltSharedStlFactory() (blueprint.Module, []interface{}) {
+func ndkPrebuiltSharedStlFactory() android.Module {
module, library := NewLibrary(android.DeviceSupported)
library.BuildOnlyShared()
linker := &ndkPrebuiltStlLinker{
@@ -147,7 +145,7 @@ func ndkPrebuiltSharedStlFactory() (blueprint.Module, []interface{}) {
return module.Init()
}
-func ndkPrebuiltStaticStlFactory() (blueprint.Module, []interface{}) {
+func ndkPrebuiltStaticStlFactory() android.Module {
module, library := NewLibrary(android.DeviceSupported)
library.BuildOnlyStatic()
linker := &ndkPrebuiltStlLinker{
diff --git a/cc/object.go b/cc/object.go
index eaddd890..14789081 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -17,8 +17,6 @@ package cc
import (
"fmt"
- "github.com/google/blueprint"
-
"android/soong/android"
)
@@ -35,7 +33,7 @@ type objectLinker struct {
Properties ObjectLinkerProperties
}
-func objectFactory() (blueprint.Module, []interface{}) {
+func objectFactory() android.Module {
module := newBaseModule(android.HostAndDeviceSupported, android.MultilibBoth)
module.linker = &objectLinker{
baseLinker: NewBaseLinker(),
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index d064a465..ac05df01 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -16,8 +16,6 @@ package cc
import (
"android/soong/android"
-
- "github.com/google/blueprint"
)
func init() {
@@ -65,7 +63,7 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
return nil
}
-func prebuiltSharedLibraryFactory() (blueprint.Module, []interface{}) {
+func prebuiltSharedLibraryFactory() android.Module {
module, _ := NewPrebuiltSharedLibrary(android.HostAndDeviceSupported)
return module.Init()
}
@@ -83,7 +81,7 @@ func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libr
return module, library
}
-func prebuiltStaticLibraryFactory() (blueprint.Module, []interface{}) {
+func prebuiltStaticLibraryFactory() android.Module {
module, _ := NewPrebuiltStaticLibrary(android.HostAndDeviceSupported)
return module.Init()
}
@@ -124,7 +122,7 @@ func (p *prebuiltBinaryLinker) link(ctx ModuleContext,
return nil
}
-func prebuiltBinaryFactory() (blueprint.Module, []interface{}) {
+func prebuiltBinaryFactory() android.Module {
module, _ := NewPrebuiltBinary(android.HostAndDeviceSupported)
return module.Init()
}
diff --git a/cc/sabi.go b/cc/sabi.go
index 92fc7cf0..9aff738b 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -17,9 +17,9 @@ package cc
import (
"strings"
- "android/soong/android"
"github.com/google/blueprint"
+ "android/soong/android"
"android/soong/cc/config"
)
diff --git a/cc/test.go b/cc/test.go
index 448f089b..ea05ba5a 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -20,8 +20,6 @@ import (
"strings"
"android/soong/android"
-
- "github.com/google/blueprint"
)
type TestProperties struct {
@@ -57,31 +55,31 @@ func init() {
}
// Module factory for tests
-func testFactory() (blueprint.Module, []interface{}) {
+func testFactory() android.Module {
module := NewTest(android.HostAndDeviceSupported)
return module.Init()
}
// Module factory for test libraries
-func testLibraryFactory() (blueprint.Module, []interface{}) {
+func testLibraryFactory() android.Module {
module := NewTestLibrary(android.HostAndDeviceSupported)
return module.Init()
}
// Module factory for benchmarks
-func benchmarkFactory() (blueprint.Module, []interface{}) {
+func benchmarkFactory() android.Module {
module := NewBenchmark(android.HostAndDeviceSupported)
return module.Init()
}
// Module factory for host tests
-func testHostFactory() (blueprint.Module, []interface{}) {
+func testHostFactory() android.Module {
module := NewTest(android.HostSupported)
return module.Init()
}
// Module factory for host benchmarks
-func benchmarkHostFactory() (blueprint.Module, []interface{}) {
+func benchmarkHostFactory() android.Module {
module := NewBenchmark(android.HostSupported)
return module.Init()
}
diff --git a/cc/test_data_test.go b/cc/test_data_test.go
index 9b5a85a7..a798919f 100644
--- a/cc/test_data_test.go
+++ b/cc/test_data_test.go
@@ -131,8 +131,10 @@ func TestDataTests(t *testing.T) {
"dir/baz": nil,
"dir/bar/baz": nil,
})
- ctx.RegisterModuleType("filegroup", genrule.FileGroupFactory)
- ctx.RegisterModuleType("test", newTest)
+ ctx.RegisterModuleType("filegroup",
+ android.ModuleFactoryAdaptor(genrule.FileGroupFactory))
+ ctx.RegisterModuleType("test",
+ android.ModuleFactoryAdaptor(newTest))
_, errs := ctx.ParseBlueprintsFiles("Blueprints")
fail(t, errs)
@@ -175,9 +177,11 @@ type testDataTest struct {
}
}
-func newTest() (blueprint.Module, []interface{}) {
+func newTest() android.Module {
m := &testDataTest{}
- return android.InitAndroidModule(m, &m.Properties)
+ m.AddProperties(&m.Properties)
+ android.InitAndroidModule(m)
+ return m
}
func (test *testDataTest) DepsMutator(ctx android.BottomUpMutatorContext) {
diff --git a/cc/toolchain_library.go b/cc/toolchain_library.go
index 1bbe7746..9b83f181 100644
--- a/cc/toolchain_library.go
+++ b/cc/toolchain_library.go
@@ -15,7 +15,6 @@
package cc
import (
- "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -38,7 +37,7 @@ func (*toolchainLibraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
return deps
}
-func toolchainLibraryFactory() (blueprint.Module, []interface{}) {
+func toolchainLibraryFactory() android.Module {
module, library := NewLibrary(android.HostAndDeviceSupported)
library.BuildOnlyStatic()
toolchainLibrary := &toolchainLibraryDecorator{