Add GetDirectDepProxyWithTag with some refactoring work.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I8187d5473a7cb55b45ed5f75fd6dabe5f3043191
diff --git a/android/module_context.go b/android/module_context.go
index b097117..b59e33d 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -440,10 +440,27 @@
}
func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) Module {
- if module, _ := m.getDirectDepInternal(name, tag); module != nil {
- return module.(Module)
+ deps := m.getDirectDepsInternal(name, tag)
+ if len(deps) == 1 {
+ return deps[0]
+ } else if len(deps) >= 2 {
+ panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
+ name, m.ModuleName()))
+ } else {
+ return nil
}
- return nil
+}
+
+func (m *moduleContext) GetDirectDepProxyWithTag(name string, tag blueprint.DependencyTag) *ModuleProxy {
+ deps := m.getDirectDepsProxyInternal(name, tag)
+ if len(deps) == 1 {
+ return &deps[0]
+ } else if len(deps) >= 2 {
+ panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
+ name, m.ModuleName()))
+ } else {
+ return nil
+ }
}
func (m *moduleContext) ModuleSubDir() string {