Fix replacements of namespace module srcs in genrule
expandSrcsForBazel always prefixed : in OriginalModuleName. The
exceptions to this are filegroups that appear in a different soong
namespace. For these cases, we were not correctly substituting the soong
module name with the equivalent bazel label.
Test: go test ./bp2build
Change-Id: If090f3f8819835177c1f4d191b3eef6bb6e30ace
diff --git a/android/bazel_paths.go b/android/bazel_paths.go
index 7992564..02ae5ca 100644
--- a/android/bazel_paths.go
+++ b/android/bazel_paths.go
@@ -378,7 +378,13 @@
if m, tag := SrcIsModuleWithTag(p); m != "" {
l := getOtherModuleLabel(ctx, m, tag, BazelModuleLabel)
if l != nil && !InList(l.Label, expandedExcludes) {
- l.OriginalModuleName = fmt.Sprintf(":%s", m)
+ if strings.HasPrefix(m, "//") {
+ // this is a module in a soong namespace
+ // It appears as //<namespace>:<module_name> in srcs, and not ://<namespace>:<module_name>
+ l.OriginalModuleName = m
+ } else {
+ l.OriginalModuleName = fmt.Sprintf(":%s", m)
+ }
labels.Includes = append(labels.Includes, *l)
}
} else {