Pass DepsContext to dependency methods

am: 37047f1c7e

Change-Id: Idee48a8b96bc21a397b81a06a86f8eb0475e770a
This commit is contained in:
Colin Cross 2016-12-14 19:35:18 +00:00 committed by android-build-merger
commit 3b4bacde17
10 changed files with 28 additions and 18 deletions

View file

@ -96,7 +96,7 @@ func (binary *binaryDecorator) getStem(ctx BaseModuleContext) string {
return stem + binary.Properties.Suffix return stem + binary.Properties.Suffix
} }
func (binary *binaryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = binary.baseLinker.linkerDeps(ctx, deps) deps = binary.baseLinker.linkerDeps(ctx, deps)
if ctx.toolchain().Bionic() { if ctx.toolchain().Bionic() {
if !Bool(binary.baseLinker.Properties.Nocrt) { if !Bool(binary.baseLinker.Properties.Nocrt) {

View file

@ -171,16 +171,21 @@ type BaseModuleContext interface {
ModuleContextIntf ModuleContextIntf
} }
type DepsContext interface {
android.BottomUpMutatorContext
ModuleContextIntf
}
type feature interface { type feature interface {
begin(ctx BaseModuleContext) begin(ctx BaseModuleContext)
deps(ctx BaseModuleContext, deps Deps) Deps deps(ctx DepsContext, deps Deps) Deps
flags(ctx ModuleContext, flags Flags) Flags flags(ctx ModuleContext, flags Flags) Flags
props() []interface{} props() []interface{}
} }
type compiler interface { type compiler interface {
compilerInit(ctx BaseModuleContext) compilerInit(ctx BaseModuleContext)
compilerDeps(ctx BaseModuleContext, deps Deps) Deps compilerDeps(ctx DepsContext, deps Deps) Deps
compilerFlags(ctx ModuleContext, flags Flags) Flags compilerFlags(ctx ModuleContext, flags Flags) Flags
compilerProps() []interface{} compilerProps() []interface{}
@ -191,7 +196,7 @@ type compiler interface {
type linker interface { type linker interface {
linkerInit(ctx BaseModuleContext) linkerInit(ctx BaseModuleContext)
linkerDeps(ctx BaseModuleContext, deps Deps) Deps linkerDeps(ctx DepsContext, deps Deps) Deps
linkerFlags(ctx ModuleContext, flags Flags) Flags linkerFlags(ctx ModuleContext, flags Flags) Flags
linkerProps() []interface{} linkerProps() []interface{}
@ -307,6 +312,11 @@ type baseModuleContext struct {
moduleContextImpl moduleContextImpl
} }
type depsContext struct {
android.BottomUpMutatorContext
moduleContextImpl
}
type moduleContext struct { type moduleContext struct {
android.ModuleContext android.ModuleContext
moduleContextImpl moduleContextImpl
@ -534,7 +544,7 @@ func (c *Module) begin(ctx BaseModuleContext) {
} }
} }
func (c *Module) deps(ctx BaseModuleContext) Deps { func (c *Module) deps(ctx DepsContext) Deps {
deps := Deps{} deps := Deps{}
if c.compiler != nil { if c.compiler != nil {
@ -604,8 +614,8 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
return return
} }
ctx := &baseModuleContext{ ctx := &depsContext{
BaseContext: actx, BottomUpMutatorContext: actx,
moduleContextImpl: moduleContextImpl{ moduleContextImpl: moduleContextImpl{
mod: c, mod: c,
}, },

View file

@ -129,7 +129,7 @@ func (compiler *baseCompiler) compilerProps() []interface{} {
func (compiler *baseCompiler) compilerInit(ctx BaseModuleContext) {} func (compiler *baseCompiler) compilerInit(ctx BaseModuleContext) {}
func (compiler *baseCompiler) compilerDeps(ctx BaseModuleContext, deps Deps) Deps { func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps.GeneratedSources = append(deps.GeneratedSources, compiler.Properties.Generated_sources...) deps.GeneratedSources = append(deps.GeneratedSources, compiler.Properties.Generated_sources...)
deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...) deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...)

View file

@ -351,7 +351,7 @@ func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) {
library.relocationPacker.packingInit(ctx) library.relocationPacker.packingInit(ctx)
} }
func (library *libraryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = library.baseLinker.linkerDeps(ctx, deps) deps = library.baseLinker.linkerDeps(ctx, deps)
if library.static() { if library.static() {

View file

@ -242,7 +242,7 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O
return compileObjs(ctx, flagsToBuilderFlags(flags), subdir, srcs, nil) return compileObjs(ctx, flagsToBuilderFlags(flags), subdir, srcs, nil)
} }
func (linker *stubDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (linker *stubDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
return Deps{} return Deps{}
} }

View file

@ -62,7 +62,7 @@ type ndkPrebuiltObjectLinker struct {
objectLinker objectLinker
} }
func (*ndkPrebuiltObjectLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (*ndkPrebuiltObjectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
// NDK objects can't have any dependencies // NDK objects can't have any dependencies
return deps return deps
} }
@ -96,7 +96,7 @@ func (ndk *ndkPrebuiltLibraryLinker) linkerProps() []interface{} {
return append(ndk.libraryDecorator.linkerProps(), &ndk.Properties, &ndk.flagExporter.Properties) return append(ndk.libraryDecorator.linkerProps(), &ndk.Properties, &ndk.flagExporter.Properties)
} }
func (*ndkPrebuiltLibraryLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (*ndkPrebuiltLibraryLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
// NDK libraries can't have any dependencies // NDK libraries can't have any dependencies
return deps return deps
} }

View file

@ -54,7 +54,7 @@ func (object *objectLinker) linkerProps() []interface{} {
func (*objectLinker) linkerInit(ctx BaseModuleContext) {} func (*objectLinker) linkerInit(ctx BaseModuleContext) {}
func (object *objectLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ObjFiles = append(deps.ObjFiles, object.Properties.Objs...) deps.ObjFiles = append(deps.ObjFiles, object.Properties.Objs...)
return deps return deps
} }

View file

@ -199,7 +199,7 @@ func (test *testBinary) linkerInit(ctx BaseModuleContext) {
test.binaryDecorator.linkerInit(ctx) test.binaryDecorator.linkerInit(ctx)
} }
func (test *testBinary) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (test *testBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = test.testDecorator.linkerDeps(ctx, deps) deps = test.testDecorator.linkerDeps(ctx, deps)
deps = test.binaryDecorator.linkerDeps(ctx, deps) deps = test.binaryDecorator.linkerDeps(ctx, deps)
return deps return deps
@ -250,7 +250,7 @@ func (test *testLibrary) linkerInit(ctx BaseModuleContext) {
test.libraryDecorator.linkerInit(ctx) test.libraryDecorator.linkerInit(ctx)
} }
func (test *testLibrary) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (test *testLibrary) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = test.testDecorator.linkerDeps(ctx, deps) deps = test.testDecorator.linkerDeps(ctx, deps)
deps = test.libraryDecorator.linkerDeps(ctx, deps) deps = test.libraryDecorator.linkerDeps(ctx, deps)
return deps return deps
@ -288,7 +288,7 @@ func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
benchmark.binaryDecorator.linkerInit(ctx) benchmark.binaryDecorator.linkerInit(ctx)
} }
func (benchmark *benchmarkDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = benchmark.binaryDecorator.linkerDeps(ctx, deps) deps = benchmark.binaryDecorator.linkerDeps(ctx, deps)
deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark") deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark")
return deps return deps

View file

@ -44,7 +44,7 @@ func (tidy *tidyFeature) props() []interface{} {
func (tidy *tidyFeature) begin(ctx BaseModuleContext) { func (tidy *tidyFeature) begin(ctx BaseModuleContext) {
} }
func (tidy *tidyFeature) deps(ctx BaseModuleContext, deps Deps) Deps { func (tidy *tidyFeature) deps(ctx DepsContext, deps Deps) Deps {
return deps return deps
} }

View file

@ -33,7 +33,7 @@ type toolchainLibraryDecorator struct {
*libraryDecorator *libraryDecorator
} }
func (*toolchainLibraryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (*toolchainLibraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
// toolchain libraries can't have any dependencies // toolchain libraries can't have any dependencies
return deps return deps
} }