diff options
author | Colin Cross <ccross@android.com> | 2016-08-01 13:20:05 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2016-08-01 13:47:15 -0700 |
commit | 42742b8bb043abd3b330defd1bfac4ed756e63ff (patch) | |
tree | 438b1b4102b92b99b63a0a6b516f14b247f20f59 | |
parent | b98c8b05954dd78d3c4bb87b0bceeb03ef4b362c (diff) | |
download | build_soong-42742b8bb043abd3b330defd1bfac4ed756e63ff.tar.gz build_soong-42742b8bb043abd3b330defd1bfac4ed756e63ff.tar.bz2 build_soong-42742b8bb043abd3b330defd1bfac4ed756e63ff.zip |
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
-rw-r--r-- | cc/binary.go | 16 | ||||
-rw-r--r-- | cc/cc.go | 34 | ||||
-rw-r--r-- | cc/compiler.go | 8 | ||||
-rw-r--r-- | cc/installer.go | 2 | ||||
-rw-r--r-- | cc/library.go | 20 | ||||
-rw-r--r-- | cc/linker.go | 8 | ||||
-rw-r--r-- | cc/ndk_library.go | 6 | ||||
-rw-r--r-- | cc/ndk_prebuilt.go | 8 | ||||
-rw-r--r-- | cc/object.go | 8 | ||||
-rw-r--r-- | cc/test.go | 44 |
10 files changed, 81 insertions, 73 deletions
diff --git a/cc/binary.go b/cc/binary.go index d6b086c0..fd64cdaf 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -67,8 +67,8 @@ type binaryLinker struct { 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 @@ func (binary *binaryLinker) getStem(ctx BaseModuleContext) string { 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 @@ func NewBinary(hod android.HostOrDeviceSupported) *Module { 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) begin(ctx BaseModuleContext) { } } -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") @@ -170,21 +170,29 @@ type feature interface { } 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 @@ func (c *Module) Init() (blueprint.Module, []interface{}) { 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 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { 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) toolchain(ctx BaseModuleContext) config.Toolchain { 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 @@ func (c *Module) deps(ctx BaseModuleContext) Deps { 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 @@ type toolchainLibraryLinker struct { 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 4c30c98e..0182491e 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -103,13 +103,13 @@ func (compiler *baseCompiler) appendAsflags(flags []string) { 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 @@ func (compiler *baseCompiler) deps(ctx BaseModuleContext, deps Deps) Deps { // 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 7dc2b78d..9a1e1fa0 100644 --- a/cc/installer.go +++ b/cc/installer.go @@ -42,7 +42,7 @@ type baseInstaller struct { 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 d92a2679..2ae18e99 100644 --- a/cc/library.go +++ b/cc/library.go @@ -149,13 +149,13 @@ type libraryCompiler struct { 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 @@ type libraryInterface interface { 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 @@ func (library *libraryLinker) getLibName(ctx ModuleContext) string { 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 @@ func (library *libraryLinker) flags(ctx ModuleContext, flags Flags) Flags { 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 c6f13f22..5b7ea8b8 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -82,7 +82,7 @@ func (linker *baseLinker) appendLdflags(flags []string) { 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) begin(ctx BaseModuleContext) { } } -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 @@ func (linker *baseLinker) deps(ctx BaseModuleContext, deps Deps) Deps { 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 50db938e..903a96bf 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -211,14 +211,14 @@ type stubLinker struct { 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 40cd2072..2b24507e 100644 --- a/cc/ndk_prebuilt.go +++ b/cc/ndk_prebuilt.go @@ -63,7 +63,7 @@ type ndkPrebuiltObjectLinker struct { 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 @@ type ndkPrebuiltLibraryLinker struct { 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 456e1bbc..fbb7b7f2 100644 --- a/cc/object.go +++ b/cc/object.go @@ -46,18 +46,18 @@ func (object *objectLinker) appendLdflags(flags []string) { 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 { @@ -93,7 +93,7 @@ type testLinker struct { 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 @@ func (test *testLinker) flags(ctx ModuleContext, flags Flags) Flags { 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 @@ type testBinaryLinker struct { 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 @@ func (test *testBinaryLinker) begin(ctx BaseModuleContext) { 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 @@ type testLibraryLinker struct { *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 @@ type benchmarkLinker struct { 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 } |