Merge "Fix possible orphaned proto_library targets" into main
diff --git a/android/proto.go b/android/proto.go
index 49b3733..b21efd6 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -283,6 +283,15 @@
}
}
+ // TODO - b/246997908: Handle potential orphaned proto_library targets
+ // To create proto_library targets in the same package, we split the .proto files
+ // This means that if a proto_library in a subpackage imports another proto_library from the parent package
+ // (or a different subpackage), it will not find it.
+ // The CcProtoGen action itself runs fine because we construct the correct ProtoInfo,
+ // but the FileDescriptorSet of each proto_library might not be compile-able
+ if pkg != ctx.ModuleDir() {
+ tags.Append(bazel.MakeStringListAttribute([]string{"manual"}))
+ }
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
CommonAttributes{Name: name, Dir: proptools.StringPtr(pkg), Tags: tags},
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index e5ae73e..622ec4a 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -4967,6 +4967,7 @@
tc.ExpectedBazelTargets = []string{
MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{
"srcs": `["//bar:bar.proto"]`,
+ "tags": `["manual"]`,
}),
}
runCcLibraryTestCase(t, tc)
@@ -4976,6 +4977,7 @@
tc.ExpectedBazelTargets = []string{
MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{
"srcs": `["//baz/subbaz:baz.proto"]`,
+ "tags": `["manual"]`,
}),
}
runCcLibraryTestCase(t, tc)
@@ -5035,6 +5037,7 @@
"srcs": `["//bar:bar.proto"]`,
"strip_import_prefix": `""`,
"import_prefix": `"bar"`,
+ "tags": `["manual"]`,
}),
}
runCcLibraryTestCase(t, tc)
@@ -5046,6 +5049,7 @@
"srcs": `["//baz/subbaz:baz.proto"]`,
"strip_import_prefix": `""`,
"import_prefix": `"baz/subbaz"`,
+ "tags": `["manual"]`,
}),
}
runCcLibraryTestCase(t, tc)