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
diff --git a/cc/binary.go b/cc/binary.go
index 7755b5f..78883fa 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -96,7 +96,7 @@
 	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) {
diff --git a/cc/cc.go b/cc/cc.go
index 3fc694f..74d3d3d 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -171,16 +171,21 @@
 	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 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 @@
 	moduleContextImpl
 }
 
+type depsContext struct {
+	android.BottomUpMutatorContext
+	moduleContextImpl
+}
+
 type moduleContext struct {
 	android.ModuleContext
 	moduleContextImpl
@@ -534,7 +544,7 @@
 	}
 }
 
-func (c *Module) deps(ctx BaseModuleContext) Deps {
+func (c *Module) deps(ctx DepsContext) Deps {
 	deps := Deps{}
 
 	if c.compiler != nil {
@@ -604,8 +614,8 @@
 		return
 	}
 
-	ctx := &baseModuleContext{
-		BaseContext: actx,
+	ctx := &depsContext{
+		BottomUpMutatorContext: actx,
 		moduleContextImpl: moduleContextImpl{
 			mod: c,
 		},
diff --git a/cc/compiler.go b/cc/compiler.go
index 99f56b7..e6f432c 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -129,7 +129,7 @@
 
 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...)
 
diff --git a/cc/library.go b/cc/library.go
index 666c47a..8474f96 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -351,7 +351,7 @@
 	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() {
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 0e42731..afa7927 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -242,7 +242,7 @@
 	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{}
 }
 
diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go
index 63f8921..676d63d 100644
--- a/cc/ndk_prebuilt.go
+++ b/cc/ndk_prebuilt.go
@@ -62,7 +62,7 @@
 	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 @@
 	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
 }
diff --git a/cc/object.go b/cc/object.go
index 16ed455..eaddd89 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -54,7 +54,7 @@
 
 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
 }
diff --git a/cc/test.go b/cc/test.go
index a2b827f..07eb621 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -199,7 +199,7 @@
 	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 @@
 	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 @@
 	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
diff --git a/cc/tidy.go b/cc/tidy.go
index 2216f58..9dcc946 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -44,7 +44,7 @@
 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
 }
 
diff --git a/cc/toolchain_library.go b/cc/toolchain_library.go
index 6ca9dc3..1bbe774 100644
--- a/cc/toolchain_library.go
+++ b/cc/toolchain_library.go
@@ -33,7 +33,7 @@
 	*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
 }