Rename compiler, linker and installer methods to be unique
compiler, linker, and installer interfaces may be implemented by a
single decorator object, rename their methods to be unique to avoid the
same method being called multiple times.
Test: out/soong/build.ninja unchanged
Change-Id: I1608c41cd68f614ba99c11bb9fcc7936f618d9aa
diff --git a/cc/binary.go b/cc/binary.go
index d6b086c..fd64cda 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -67,8 +67,8 @@
var _ linker = (*binaryLinker)(nil)
-func (binary *binaryLinker) props() []interface{} {
- return append(binary.baseLinker.props(),
+func (binary *binaryLinker) linkerProps() []interface{} {
+ return append(binary.baseLinker.linkerProps(),
&binary.Properties,
&binary.stripper.StripProperties)
@@ -91,8 +91,8 @@
return stem + binary.Properties.Suffix
}
-func (binary *binaryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
- deps = binary.baseLinker.deps(ctx, deps)
+func (binary *binaryLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
+ deps = binary.baseLinker.linkerDeps(ctx, deps)
if ctx.Device() {
if !Bool(binary.baseLinker.Properties.Nocrt) {
if !ctx.sdk() {
@@ -155,8 +155,8 @@
return module
}
-func (binary *binaryLinker) begin(ctx BaseModuleContext) {
- binary.baseLinker.begin(ctx)
+func (binary *binaryLinker) linkerInit(ctx BaseModuleContext) {
+ binary.baseLinker.linkerInit(ctx)
static := Bool(binary.Properties.Static_executable)
if ctx.Host() {
@@ -175,8 +175,8 @@
}
}
-func (binary *binaryLinker) flags(ctx ModuleContext, flags Flags) Flags {
- flags = binary.baseLinker.flags(ctx, flags)
+func (binary *binaryLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
+ flags = binary.baseLinker.linkerFlags(ctx, flags)
if ctx.Host() && !binary.staticBinary() {
flags.LdFlags = append(flags.LdFlags, "-pie")
diff --git a/cc/cc.go b/cc/cc.go
index 5385eaa..8c2fe6f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -170,21 +170,29 @@
}
type compiler interface {
- feature
+ compilerInit(ctx BaseModuleContext)
+ compilerDeps(ctx BaseModuleContext, deps Deps) Deps
+ compilerFlags(ctx ModuleContext, flags Flags) Flags
+ compilerProps() []interface{}
+
appendCflags([]string)
appendAsflags([]string)
compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths
}
type linker interface {
- feature
+ linkerInit(ctx BaseModuleContext)
+ linkerDeps(ctx BaseModuleContext, deps Deps) Deps
+ linkerFlags(ctx ModuleContext, flags Flags) Flags
+ linkerProps() []interface{}
+
link(ctx ModuleContext, flags Flags, deps PathDeps, objFiles android.Paths) android.Path
appendLdflags([]string)
installable() bool
}
type installer interface {
- props() []interface{}
+ installerProps() []interface{}
install(ctx ModuleContext, path android.Path)
inData() bool
}
@@ -251,13 +259,13 @@
props = append(props, c.Customizer.Properties()...)
}
if c.compiler != nil {
- props = append(props, c.compiler.props()...)
+ props = append(props, c.compiler.compilerProps()...)
}
if c.linker != nil {
- props = append(props, c.linker.props()...)
+ props = append(props, c.linker.linkerProps()...)
}
if c.installer != nil {
- props = append(props, c.installer.props()...)
+ props = append(props, c.installer.installerProps()...)
}
if c.stl != nil {
props = append(props, c.stl.props()...)
@@ -391,10 +399,10 @@
Clang: c.clang(ctx),
}
if c.compiler != nil {
- flags = c.compiler.flags(ctx, flags)
+ flags = c.compiler.compilerFlags(ctx, flags)
}
if c.linker != nil {
- flags = c.linker.flags(ctx, flags)
+ flags = c.linker.linkerFlags(ctx, flags)
}
if c.stl != nil {
flags = c.stl.flags(ctx, flags)
@@ -462,10 +470,10 @@
func (c *Module) begin(ctx BaseModuleContext) {
if c.compiler != nil {
- c.compiler.begin(ctx)
+ c.compiler.compilerInit(ctx)
}
if c.linker != nil {
- c.linker.begin(ctx)
+ c.linker.linkerInit(ctx)
}
if c.stl != nil {
c.stl.begin(ctx)
@@ -482,10 +490,10 @@
deps := Deps{}
if c.compiler != nil {
- deps = c.compiler.deps(ctx, deps)
+ deps = c.compiler.compilerDeps(ctx, deps)
}
if c.linker != nil {
- deps = c.linker.deps(ctx, deps)
+ deps = c.linker.linkerDeps(ctx, deps)
}
if c.stl != nil {
deps = c.stl.deps(ctx, deps)
@@ -850,7 +858,7 @@
var _ baseLinkerInterface = (*toolchainLibraryLinker)(nil)
-func (*toolchainLibraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
+func (*toolchainLibraryLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
// toolchain libraries can't have any dependencies
return deps
}
diff --git a/cc/compiler.go b/cc/compiler.go
index 4c30c98..0182491 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -103,13 +103,13 @@
compiler.Properties.Asflags = append(compiler.Properties.Asflags, flags...)
}
-func (compiler *baseCompiler) props() []interface{} {
+func (compiler *baseCompiler) compilerProps() []interface{} {
return []interface{}{&compiler.Properties}
}
-func (compiler *baseCompiler) begin(ctx BaseModuleContext) {}
+func (compiler *baseCompiler) compilerInit(ctx BaseModuleContext) {}
-func (compiler *baseCompiler) deps(ctx BaseModuleContext, deps Deps) Deps {
+func (compiler *baseCompiler) compilerDeps(ctx BaseModuleContext, deps Deps) Deps {
deps.GeneratedSources = append(deps.GeneratedSources, compiler.Properties.Generated_sources...)
deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...)
@@ -118,7 +118,7 @@
// Create a Flags struct that collects the compile flags from global values,
// per-target values, module type values, and per-module Blueprints properties
-func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
+func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flags {
tc := ctx.toolchain()
CheckBadCompilerFlags(ctx, "cflags", compiler.Properties.Cflags)
diff --git a/cc/installer.go b/cc/installer.go
index 7dc2b78..9a1e1fa 100644
--- a/cc/installer.go
+++ b/cc/installer.go
@@ -42,7 +42,7 @@
var _ installer = (*baseInstaller)(nil)
-func (installer *baseInstaller) props() []interface{} {
+func (installer *baseInstaller) installerProps() []interface{} {
return []interface{}{&installer.Properties}
}
diff --git a/cc/library.go b/cc/library.go
index d92a267..2ae18e9 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -149,13 +149,13 @@
var _ compiler = (*libraryCompiler)(nil)
-func (library *libraryCompiler) props() []interface{} {
- props := library.baseCompiler.props()
+func (library *libraryCompiler) compilerProps() []interface{} {
+ props := library.baseCompiler.compilerProps()
return append(props, &library.Properties)
}
-func (library *libraryCompiler) flags(ctx ModuleContext, flags Flags) Flags {
- flags = library.baseCompiler.flags(ctx, flags)
+func (library *libraryCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flags {
+ flags = library.baseCompiler.compilerFlags(ctx, flags)
// MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
// all code is position independent, and then those warnings get promoted to
@@ -227,8 +227,8 @@
objs() android.Paths
}
-func (library *libraryLinker) props() []interface{} {
- props := library.baseLinker.props()
+func (library *libraryLinker) linkerProps() []interface{} {
+ props := library.baseLinker.linkerProps()
return append(props,
&library.Properties,
&library.dynamicProperties,
@@ -251,8 +251,8 @@
return name + library.Properties.VariantName
}
-func (library *libraryLinker) flags(ctx ModuleContext, flags Flags) Flags {
- flags = library.baseLinker.flags(ctx, flags)
+func (library *libraryLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
+ flags = library.baseLinker.linkerFlags(ctx, flags)
if !library.static() {
libName := library.getLibName(ctx)
@@ -288,8 +288,8 @@
return flags
}
-func (library *libraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
- deps = library.baseLinker.deps(ctx, deps)
+func (library *libraryLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
+ deps = library.baseLinker.linkerDeps(ctx, deps)
if library.static() {
deps.WholeStaticLibs = append(deps.WholeStaticLibs, library.Properties.Static.Whole_static_libs...)
deps.StaticLibs = append(deps.StaticLibs, library.Properties.Static.Static_libs...)
diff --git a/cc/linker.go b/cc/linker.go
index c6f13f2..5b7ea8b 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -82,7 +82,7 @@
linker.Properties.Ldflags = append(linker.Properties.Ldflags, flags...)
}
-func (linker *baseLinker) begin(ctx BaseModuleContext) {
+func (linker *baseLinker) linkerInit(ctx BaseModuleContext) {
if ctx.toolchain().Is64Bit() {
linker.dynamicProperties.RunPaths = []string{"../lib64", "lib64"}
} else {
@@ -90,11 +90,11 @@
}
}
-func (linker *baseLinker) props() []interface{} {
+func (linker *baseLinker) linkerProps() []interface{} {
return []interface{}{&linker.Properties, &linker.dynamicProperties}
}
-func (linker *baseLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
+func (linker *baseLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
deps.WholeStaticLibs = append(deps.WholeStaticLibs, linker.Properties.Whole_static_libs...)
deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Static_libs...)
deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Shared_libs...)
@@ -133,7 +133,7 @@
return deps
}
-func (linker *baseLinker) flags(ctx ModuleContext, flags Flags) Flags {
+func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
toolchain := ctx.toolchain()
flags.Nocrt = Bool(linker.Properties.Nocrt)
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 50db938..903a96b 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -211,14 +211,14 @@
libraryLinker
}
-func (linker *stubLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
+func (linker *stubLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
return Deps{}
}
-func (linker *stubLinker) flags(ctx ModuleContext, flags Flags) Flags {
+func (linker *stubLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
linker.libraryLinker.libName = strings.TrimSuffix(ctx.ModuleName(),
ndkLibrarySuffix)
- return linker.libraryLinker.flags(ctx, flags)
+ return linker.libraryLinker.linkerFlags(ctx, flags)
}
type stubInstaller struct {
diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go
index 40cd207..2b24507 100644
--- a/cc/ndk_prebuilt.go
+++ b/cc/ndk_prebuilt.go
@@ -63,7 +63,7 @@
objectLinker
}
-func (*ndkPrebuiltObjectLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
+func (*ndkPrebuiltObjectLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
// NDK objects can't have any dependencies
return deps
}
@@ -92,11 +92,11 @@
var _ baseLinkerInterface = (*ndkPrebuiltLibraryLinker)(nil)
var _ exportedFlagsProducer = (*libraryLinker)(nil)
-func (ndk *ndkPrebuiltLibraryLinker) props() []interface{} {
- return append(ndk.libraryLinker.props(), &ndk.Properties, &ndk.flagExporter.Properties)
+func (ndk *ndkPrebuiltLibraryLinker) linkerProps() []interface{} {
+ return append(ndk.libraryLinker.linkerProps(), &ndk.Properties, &ndk.flagExporter.Properties)
}
-func (*ndkPrebuiltLibraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
+func (*ndkPrebuiltLibraryLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
// NDK libraries can't have any dependencies
return deps
}
diff --git a/cc/object.go b/cc/object.go
index 456e1bb..fbb7b7f 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -46,18 +46,18 @@
panic(fmt.Errorf("appendLdflags on object Linker not supported"))
}
-func (object *objectLinker) props() []interface{} {
+func (object *objectLinker) linkerProps() []interface{} {
return []interface{}{&object.Properties}
}
-func (*objectLinker) begin(ctx BaseModuleContext) {}
+func (*objectLinker) linkerInit(ctx BaseModuleContext) {}
-func (object *objectLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
+func (object *objectLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
deps.ObjFiles = append(deps.ObjFiles, object.Properties.Objs...)
return deps
}
-func (*objectLinker) flags(ctx ModuleContext, flags Flags) Flags {
+func (*objectLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
if flags.Clang {
flags.LdFlags = append(flags.LdFlags, ctx.toolchain().ToolchainClangLdflags())
} else {
diff --git a/cc/test.go b/cc/test.go
index 9eb4e21..d9b8571 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -93,7 +93,7 @@
Properties TestLinkerProperties
}
-func (test *testLinker) flags(ctx ModuleContext, flags Flags) Flags {
+func (test *testLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
if !test.Properties.Gtest {
return flags
}
@@ -119,7 +119,7 @@
return flags
}
-func (test *testLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
+func (test *testLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
if test.Properties.Gtest {
if ctx.sdk() && ctx.Device() {
switch ctx.selectedStl() {
@@ -142,8 +142,8 @@
binaryLinker
}
-func (test *testBinaryLinker) begin(ctx BaseModuleContext) {
- test.binaryLinker.begin(ctx)
+func (test *testBinaryLinker) linkerInit(ctx BaseModuleContext) {
+ test.binaryLinker.linkerInit(ctx)
runpath := "../../lib"
if ctx.toolchain().Is64Bit() {
runpath += "64"
@@ -151,19 +151,19 @@
test.dynamicProperties.RunPaths = append([]string{runpath}, test.dynamicProperties.RunPaths...)
}
-func (test *testBinaryLinker) props() []interface{} {
- return append(test.binaryLinker.props(), &test.testLinker.Properties)
+func (test *testBinaryLinker) linkerProps() []interface{} {
+ return append(test.binaryLinker.linkerProps(), &test.testLinker.Properties)
}
-func (test *testBinaryLinker) flags(ctx ModuleContext, flags Flags) Flags {
- flags = test.binaryLinker.flags(ctx, flags)
- flags = test.testLinker.flags(ctx, flags)
+func (test *testBinaryLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
+ flags = test.binaryLinker.linkerFlags(ctx, flags)
+ flags = test.testLinker.linkerFlags(ctx, flags)
return flags
}
-func (test *testBinaryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
- deps = test.testLinker.deps(ctx, deps)
- deps = test.binaryLinker.deps(ctx, deps)
+func (test *testBinaryLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
+ deps = test.testLinker.linkerDeps(ctx, deps)
+ deps = test.binaryLinker.linkerDeps(ctx, deps)
return deps
}
@@ -172,19 +172,19 @@
*libraryLinker
}
-func (test *testLibraryLinker) props() []interface{} {
- return append(test.libraryLinker.props(), &test.testLinker.Properties)
+func (test *testLibraryLinker) linkerProps() []interface{} {
+ return append(test.libraryLinker.linkerProps(), &test.testLinker.Properties)
}
-func (test *testLibraryLinker) flags(ctx ModuleContext, flags Flags) Flags {
- flags = test.libraryLinker.flags(ctx, flags)
- flags = test.testLinker.flags(ctx, flags)
+func (test *testLibraryLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
+ flags = test.libraryLinker.linkerFlags(ctx, flags)
+ flags = test.testLinker.linkerFlags(ctx, flags)
return flags
}
-func (test *testLibraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
- deps = test.testLinker.deps(ctx, deps)
- deps = test.libraryLinker.deps(ctx, deps)
+func (test *testLibraryLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
+ deps = test.testLinker.linkerDeps(ctx, deps)
+ deps = test.libraryLinker.linkerDeps(ctx, deps)
return deps
}
@@ -235,8 +235,8 @@
testBinaryLinker
}
-func (benchmark *benchmarkLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
- deps = benchmark.testBinaryLinker.deps(ctx, deps)
+func (benchmark *benchmarkLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
+ deps = benchmark.testBinaryLinker.linkerDeps(ctx, deps)
deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark")
return deps
}