Pass DepsContext to dependency methods
Pass a DepsContext that embeds android.BottomUpMutatorContext instead of android.BaseContext so that dependency methods can directly add dependencies. Test: m -j Change-Id: Id4c157975d3d6f03efd99785d217bef486a76139
This commit is contained in:
parent
5950f3827c
commit
37047f1c7e
|
@ -96,7 +96,7 @@ func (binary *binaryDecorator) getStem(ctx BaseModuleContext) string {
|
|||
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)
|
||||
if ctx.toolchain().Bionic() {
|
||||
if !Bool(binary.baseLinker.Properties.Nocrt) {
|
||||
|
|
22
cc/cc.go
22
cc/cc.go
|
@ -171,16 +171,21 @@ type BaseModuleContext interface {
|
|||
ModuleContextIntf
|
||||
}
|
||||
|
||||
type DepsContext interface {
|
||||
android.BottomUpMutatorContext
|
||||
ModuleContextIntf
|
||||
}
|
||||
|
||||
type feature interface {
|
||||
begin(ctx BaseModuleContext)
|
||||
deps(ctx BaseModuleContext, deps Deps) Deps
|
||||
deps(ctx DepsContext, deps Deps) Deps
|
||||
flags(ctx ModuleContext, flags Flags) Flags
|
||||
props() []interface{}
|
||||
}
|
||||
|
||||
type compiler interface {
|
||||
compilerInit(ctx BaseModuleContext)
|
||||
compilerDeps(ctx BaseModuleContext, deps Deps) Deps
|
||||
compilerDeps(ctx DepsContext, deps Deps) Deps
|
||||
compilerFlags(ctx ModuleContext, flags Flags) Flags
|
||||
compilerProps() []interface{}
|
||||
|
||||
|
@ -191,7 +196,7 @@ type compiler interface {
|
|||
|
||||
type linker interface {
|
||||
linkerInit(ctx BaseModuleContext)
|
||||
linkerDeps(ctx BaseModuleContext, deps Deps) Deps
|
||||
linkerDeps(ctx DepsContext, deps Deps) Deps
|
||||
linkerFlags(ctx ModuleContext, flags Flags) Flags
|
||||
linkerProps() []interface{}
|
||||
|
||||
|
@ -307,6 +312,11 @@ type baseModuleContext struct {
|
|||
moduleContextImpl
|
||||
}
|
||||
|
||||
type depsContext struct {
|
||||
android.BottomUpMutatorContext
|
||||
moduleContextImpl
|
||||
}
|
||||
|
||||
type moduleContext struct {
|
||||
android.ModuleContext
|
||||
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{}
|
||||
|
||||
if c.compiler != nil {
|
||||
|
@ -604,8 +614,8 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx := &baseModuleContext{
|
||||
BaseContext: actx,
|
||||
ctx := &depsContext{
|
||||
BottomUpMutatorContext: actx,
|
||||
moduleContextImpl: moduleContextImpl{
|
||||
mod: c,
|
||||
},
|
||||
|
|
|
@ -129,7 +129,7 @@ func (compiler *baseCompiler) compilerProps() []interface{} {
|
|||
|
||||
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.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...)
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) {
|
|||
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)
|
||||
|
||||
if library.static() {
|
||||
|
|
|
@ -242,7 +242,7 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O
|
|||
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{}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ type ndkPrebuiltObjectLinker struct {
|
|||
objectLinker
|
||||
}
|
||||
|
||||
func (*ndkPrebuiltObjectLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
|
||||
func (*ndkPrebuiltObjectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
// NDK objects can't have any dependencies
|
||||
return deps
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ func (ndk *ndkPrebuiltLibraryLinker) linkerProps() []interface{} {
|
|||
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
|
||||
return deps
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ func (object *objectLinker) linkerProps() []interface{} {
|
|||
|
||||
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...)
|
||||
return deps
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ func (test *testBinary) linkerInit(ctx BaseModuleContext) {
|
|||
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.binaryDecorator.linkerDeps(ctx, deps)
|
||||
return deps
|
||||
|
@ -250,7 +250,7 @@ func (test *testLibrary) linkerInit(ctx BaseModuleContext) {
|
|||
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.libraryDecorator.linkerDeps(ctx, deps)
|
||||
return deps
|
||||
|
@ -288,7 +288,7 @@ func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
|
|||
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.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark")
|
||||
return deps
|
||||
|
|
|
@ -44,7 +44,7 @@ func (tidy *tidyFeature) props() []interface{} {
|
|||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ type toolchainLibraryDecorator struct {
|
|||
*libraryDecorator
|
||||
}
|
||||
|
||||
func (*toolchainLibraryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
|
||||
func (*toolchainLibraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
// toolchain libraries can't have any dependencies
|
||||
return deps
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue