diff options
author | 2021-07-21 14:34:58 -0400 | |
---|---|---|
committer | 2021-07-22 18:09:34 -0400 | |
commit | 5a34ffb350fb295780e5c373fd1c78430fa4e3ed (patch) | |
tree | ba92f8cc0df67952df148cd23b1230456fb32021 /android/module.go | |
parent | 561923e10d6cf55f40b3be47aa1d179f1c4524de (diff) |
Remove bp2build deps mutator
Refactor bp2build to retrieve modules directly by name, instead of via
DirectDeps. This functions properly as bp2build has no need for variant
information of the blueprint graph.
Test: USE_BAZEL_ANALYSIS=1 m fmtlib
Change-Id: Ief4b67bc56f24929871af772f3a742f07085bf8c
Diffstat (limited to 'android/module.go')
-rw-r--r-- | android/module.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/android/module.go b/android/module.go index 11f63bd49..4dd580083 100644 --- a/android/module.go +++ b/android/module.go @@ -223,6 +223,8 @@ type BaseModuleContext interface { // the first DependencyTag. GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) + ModuleFromName(name string) (blueprint.Module, bool) + // VisitDirectDepsBlueprint calls visit for each direct dependency. If there are multiple // direct dependencies on the same module visit will be called multiple times on that module // and OtherModuleDependencyTag will return a different tag for each. @@ -2032,8 +2034,13 @@ type baseModuleContext struct { tagPath []blueprint.DependencyTag strictVisitDeps bool // If true, enforce that all dependencies are enabled + + bazelConversionMode bool } +func (b *baseModuleContext) BazelConversionMode() bool { + return b.bazelConversionMode +} func (b *baseModuleContext) OtherModuleName(m blueprint.Module) string { return b.bp.OtherModuleName(m) } @@ -2373,6 +2380,18 @@ func (b *baseModuleContext) GetDirectDep(name string) (blueprint.Module, bluepri return b.getDirectDepFirstTag(name) } +func (b *baseModuleContext) ModuleFromName(name string) (blueprint.Module, bool) { + if !b.BazelConversionMode() { + panic("cannot call ModuleFromName if not in bazel conversion mode") + } + if len(name) > 1 && (name[0] == ':' || (name[0] == '/' && name[1] == '/')) { + moduleName, _ := SrcIsModuleWithTag(name) + return b.bp.ModuleFromName(moduleName) + } else { + return b.bp.ModuleFromName(name) + } +} + func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) { b.bp.VisitDirectDeps(visit) } |