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
diff --git a/cc/object.go b/cc/object.go
index 0327a45..bd43e36 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -29,7 +29,6 @@
android.RegisterModuleType("cc_object", ObjectFactory)
android.RegisterSdkMemberType(ccObjectSdkMemberType)
- android.RegisterBp2BuildMutator("cc_object", ObjectBp2Build)
}
var ccObjectSdkMemberType = &librarySdkMemberType{
@@ -117,6 +116,7 @@
module.sdkMemberTypes = []android.SdkMemberType{ccObjectSdkMemberType}
+ module.bazelable = true
return module.Init()
}
@@ -135,19 +135,9 @@
Linker_script bazel.LabelAttribute
}
-// ObjectBp2Build is the bp2build converter from cc_object modules to the
+// objectBp2Build is the bp2build converter from cc_object modules to the
// Bazel equivalent target, plus any necessary include deps for the cc_object.
-func ObjectBp2Build(ctx android.TopDownMutatorContext) {
- m, ok := ctx.Module().(*Module)
- if !ok || !m.ConvertWithBp2build(ctx) {
- return
- }
-
- // a Module can be something other than a cc_object.
- if ctx.ModuleType() != "cc_object" {
- return
- }
-
+func objectBp2Build(ctx android.TopDownMutatorContext, m *Module) {
if m.compiler == nil {
// a cc_object must have access to the compiler decorator for its props.
ctx.ModuleErrorf("compiler must not be nil for a cc_object module")