Special-case go modules in convertedToBazel
This function is called in getOtherModuleLabel, and is used to mark the
otherModule as an unconvertedDep. This meant that if a soong module `A`
depends on soong_zip, it would add soong_zip as unconverted dep of `A`.
All go modules have been converted in bp2build, so this CL special
cases go_package and go_binary in this function.
Bug: 294098662
Test: printf metrics in build_conversion.go# GenerateBazelTargets, and
made sure that the string "has unconverted.*soong_zip" does not appear
Change-Id: I8d1d0876c581f9b2eb72dafcb3a28bd5577bbb4c
diff --git a/android/bazel.go b/android/bazel.go
index 0d2c777..df30ff2 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -22,6 +22,7 @@
"android/soong/ui/metrics/bp2build_metrics_proto"
"github.com/google/blueprint"
+ "github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/proptools"
"android/soong/android/allowlists"
@@ -426,8 +427,23 @@
return ModuleIncompatibility
}
+func isGoModule(module blueprint.Module) bool {
+ if _, ok := module.(*bootstrap.GoPackage); ok {
+ return true
+ }
+ if _, ok := module.(*bootstrap.GoBinary); ok {
+ return true
+ }
+ return false
+}
+
// ConvertedToBazel returns whether this module has been converted (with bp2build or manually) to Bazel.
func convertedToBazel(ctx BazelConversionContext, module blueprint.Module) bool {
+ // Special-case bootstrap_go_package and bootstrap_go_binary
+ // These do not implement Bazelable, but have been converted
+ if isGoModule(module) {
+ return true
+ }
b, ok := module.(Bazelable)
if !ok {
return false