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/java/java.go b/java/java.go
index 4f31af6..d5aeb7c 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2775,7 +2775,7 @@
Additional_resources bazel.LabelListAttribute
}
-func (m *Library) getResourceFilegroupStripPrefix(ctx android.TopDownMutatorContext, resourceFilegroup string) (*string, bool) {
+func (m *Library) getResourceFilegroupStripPrefix(ctx android.Bp2buildMutatorContext, resourceFilegroup string) (*string, bool) {
if otherM, ok := ctx.ModuleFromName(resourceFilegroup); ok {
if fg, isFilegroup := otherM.(android.FileGroupPath); isFilegroup {
return proptools.StringPtr(filepath.Join(ctx.OtherModuleDir(otherM), fg.GetPath(ctx))), true
@@ -2784,7 +2784,7 @@
return proptools.StringPtr(""), false
}
-func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorContext) *javaResourcesAttributes {
+func (m *Library) convertJavaResourcesAttributes(ctx android.Bp2buildMutatorContext) *javaResourcesAttributes {
var resources bazel.LabelList
var resourceStripPrefix *string
@@ -2915,7 +2915,7 @@
// which has other non-attribute information needed for bp2build conversion
// that needs different handling depending on the module types, and thus needs
// to be returned to the calling function.
-func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) (*javaCommonAttributes, *bp2BuildJavaInfo, bool) {
+func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext) (*javaCommonAttributes, *bp2BuildJavaInfo, bool) {
var srcs bazel.LabelListAttribute
var deps bazel.LabelListAttribute
var staticDeps bazel.LabelListAttribute
@@ -3136,7 +3136,7 @@
}
}
-func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
+func javaLibraryBp2Build(ctx android.Bp2buildMutatorContext, m *Library) {
commonAttrs, bp2BuildInfo, supported := m.convertLibraryAttrsBp2Build(ctx)
if !supported {
return
@@ -3192,7 +3192,7 @@
}
// JavaBinaryHostBp2Build is for java_binary_host bp2build.
-func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) {
+func javaBinaryHostBp2Build(ctx android.Bp2buildMutatorContext, m *Binary) {
commonAttrs, bp2BuildInfo, supported := m.convertLibraryAttrsBp2Build(ctx)
if !supported {
return
@@ -3279,7 +3279,7 @@
}
// javaTestHostBp2Build is for java_test_host bp2build.
-func javaTestHostBp2Build(ctx android.TopDownMutatorContext, m *TestHost) {
+func javaTestHostBp2Build(ctx android.Bp2buildMutatorContext, m *TestHost) {
commonAttrs, bp2BuildInfo, supported := m.convertLibraryAttrsBp2Build(ctx)
if !supported {
return
@@ -3332,7 +3332,7 @@
// helper function that creates java_library target from java_binary_host or java_test_host,
// and returns the library target name,
-func createLibraryTarget(ctx android.TopDownMutatorContext, libInfo libraryCreationInfo) string {
+func createLibraryTarget(ctx android.Bp2buildMutatorContext, libInfo libraryCreationInfo) string {
libName := libInfo.baseName + "_lib"
var libProps bazel.BazelTargetModuleProperties
if libInfo.hasKotlin {
@@ -3355,7 +3355,7 @@
}
// java_import bp2Build converter.
-func (i *Import) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
+func (i *Import) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
var jars bazel.LabelListAttribute
archVariantProps := i.GetArchVariantProperties(ctx, &ImportProperties{})
for axis, configToProps := range archVariantProps {