Merge "Remove bp2build deps mutator"

This commit is contained in:
Christopher Parsons
2021-07-23 14:55:40 +00:00
committed by Gerrit Code Review
11 changed files with 56 additions and 232 deletions

View File

@@ -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.
@@ -2037,8 +2039,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)
}
@@ -2378,6 +2385,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)
}