Use one mutator for all bp2build conversion.
Each conversion required defining a separate mutator, which will each operate on _all_ modules and requires each to repeat checks whether the mutator should operator. Instead, we introduce a single mutator and modules can define a ConvertWithBp2build to implement bp2build conversion for that module. Test: bp2build.sh Bug: 183079158 Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
This commit is contained in:
@@ -22,7 +22,6 @@ import (
|
||||
|
||||
func init() {
|
||||
RegisterModuleType("filegroup", FileGroupFactory)
|
||||
RegisterBp2BuildMutator("filegroup", FilegroupBp2Build)
|
||||
}
|
||||
|
||||
var PrepareForTestWithFilegroup = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||
@@ -34,12 +33,8 @@ type bazelFilegroupAttributes struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
func FilegroupBp2Build(ctx TopDownMutatorContext) {
|
||||
fg, ok := ctx.Module().(*fileGroup)
|
||||
if !ok || !fg.ConvertWithBp2build(ctx) {
|
||||
return
|
||||
}
|
||||
|
||||
// ConvertWithBp2build performs bp2build conversion of filegroup
|
||||
func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) {
|
||||
srcs := bazel.MakeLabelListAttribute(
|
||||
BazelLabelForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs))
|
||||
|
||||
|
Reference in New Issue
Block a user