Merge "Special-case go modules in convertedToBazel" into main am: fac9d8e71d

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2691135

Change-Id: I4209ae7a704eec89924df70f44ca3693f1670813
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Spandan Das
2023-08-03 17:31:19 +00:00
committed by Automerger Merge Worker
2 changed files with 17 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ import (
"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 @@ func MixedBuildsEnabled(ctx BaseModuleContext) MixedBuildEnabledStatus {
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

View File

@@ -431,7 +431,7 @@ func getOtherModuleLabel(ctx BazelConversionPathContext, dep, tag string,
func BazelModuleLabel(ctx BazelConversionPathContext, module blueprint.Module) string {
// TODO(b/165114590): Convert tag (":name{.tag}") to corresponding Bazel implicit output targets.
if !convertedToBazel(ctx, module) {
if !convertedToBazel(ctx, module) || isGoModule(module) {
return bp2buildModuleLabel(ctx, module)
}
b, _ := module.(Bazelable)