Have ConvertWBp2build use Bp2buildMutatorContext
This no-op refactoring facilitates some upcoming functional changes for
"bp2build allowlist v2". The work requires that the bp2build conversion
mutator be changed from a TopDown mutator to a BottomUp mutator.
Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext
makes it easier to make this functional change without touching tens of
files and multiple projects.
Bug: 285631638
Test: m bp2build
Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2
diff --git a/rust/binary.go b/rust/binary.go
index 1e24beb..1408ff1 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -15,9 +15,10 @@
package rust
import (
+ "fmt"
+
"android/soong/android"
"android/soong/bazel"
- "fmt"
)
func init() {
@@ -199,7 +200,7 @@
Rustc_flags bazel.StringListAttribute
}
-func binaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
+func binaryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
binary := m.compiler.(*binaryDecorator)
var srcs bazel.LabelList
diff --git a/rust/library.go b/rust/library.go
index 3f031c1..0357086 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -810,7 +810,7 @@
Proc_macro_deps bazel.LabelListAttribute
}
-func libraryBp2build(ctx android.TopDownMutatorContext, m *Module) {
+func libraryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
lib := m.compiler.(*libraryDecorator)
srcs, compileData := srcsAndCompileDataAttrs(ctx, *lib.baseCompiler)
@@ -887,7 +887,7 @@
Version bazel.StringAttribute
}
-func cargoBuildScriptBp2build(ctx android.TopDownMutatorContext, m *Module) *string {
+func cargoBuildScriptBp2build(ctx android.Bp2buildMutatorContext, m *Module) *string {
// Soong treats some crates like libprotobuf as special in that they have
// cargo build script ran to produce an out folder and check it into AOSP
// For example, https://cs.android.com/android/platform/superproject/main/+/main:external/rust/crates/protobuf/out/
diff --git a/rust/proc_macro.go b/rust/proc_macro.go
index 26227d0..b93b24f 100644
--- a/rust/proc_macro.go
+++ b/rust/proc_macro.go
@@ -15,9 +15,10 @@
package rust
import (
+ "fmt"
+
"android/soong/android"
"android/soong/bazel"
- "fmt"
)
func init() {
@@ -114,7 +115,7 @@
Rustc_flags bazel.StringListAttribute
}
-func procMacroBp2build(ctx android.TopDownMutatorContext, m *Module) {
+func procMacroBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
procMacro := m.compiler.(*procMacroDecorator)
srcs, compileData := srcsAndCompileDataAttrs(ctx, *procMacro.baseCompiler)
deps := android.BazelLabelForModuleDeps(ctx, append(
diff --git a/rust/protobuf.go b/rust/protobuf.go
index ae82844..c8d2bda 100644
--- a/rust/protobuf.go
+++ b/rust/protobuf.go
@@ -282,7 +282,7 @@
Srcs bazel.LabelListAttribute
}
-func protoLibraryBp2build(ctx android.TopDownMutatorContext, m *Module) {
+func protoLibraryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
var protoFiles []string
for _, propsInterface := range m.sourceProvider.SourceProviderProps() {
diff --git a/rust/rust.go b/rust/rust.go
index 1ee99cd..3b24484 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -15,11 +15,12 @@
package rust
import (
+ "fmt"
+ "strings"
+
"android/soong/bazel"
"android/soong/bloaty"
"android/soong/ui/metrics/bp2build_metrics_proto"
- "fmt"
- "strings"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -1845,7 +1846,7 @@
return ""
}
-func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
+func (m *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ctx.ModuleType() == "rust_library_host" || ctx.ModuleType() == "rust_library" {
libraryBp2build(ctx, m)
} else if ctx.ModuleType() == "rust_proc_macro" {
@@ -1864,7 +1865,7 @@
// TODO(b/297344471): When crate_root prop is set which enforces inputs sandboxing,
// always use `srcs` and `compile_data` props to generate `srcs` and `compile_data` attributes
// instead of using globs.
-func srcsAndCompileDataAttrs(ctx android.TopDownMutatorContext, c baseCompiler) (bazel.LabelList, bazel.LabelList) {
+func srcsAndCompileDataAttrs(ctx android.Bp2buildMutatorContext, c baseCompiler) (bazel.LabelList, bazel.LabelList) {
var srcs bazel.LabelList
var compileData bazel.LabelList