convert java proto libraries with bp2build

Allow java_libraries that depend on protobufs to be converted with
bp2build.

Bug: 215230097
Test: build/bazel/ci/bp2build.sh
Change-Id: I3ce52389e7e4e82755605ee277c1e527a6aebc6b
This commit is contained in:
Sam Delmerico
2022-02-04 21:01:20 +00:00
parent 5ee913f527
commit c768102bce
7 changed files with 229 additions and 31 deletions

View File

@@ -2013,8 +2013,16 @@ type javaLibraryAttributes struct {
func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) *javaLibraryAttributes {
//TODO(b/209577426): Support multiple arch variants
srcs := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrcExcludes(ctx, m.properties.Srcs, m.properties.Exclude_srcs))
javaSrcPartition := "java"
protoSrcPartition := "proto"
srcPartitions := bazel.PartitionLabelListAttribute(ctx, &srcs, bazel.LabelPartitions{
javaSrcPartition: bazel.LabelPartition{Extensions: []string{".java"}, Keep_remainder: true},
protoSrcPartition: android.ProtoSrcLabelPartition,
})
attrs := &javaLibraryAttributes{
Srcs: srcs,
Srcs: srcPartitions[javaSrcPartition],
}
if m.properties.Javacflags != nil {
@@ -2029,6 +2037,12 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
//TODO(b/217236083) handle static libs similarly to Soong
deps.Append(android.BazelLabelForModuleDeps(ctx, m.properties.Static_libs))
}
protoDeps := bp2buildProto(ctx, &m.Module, srcPartitions[protoSrcPartition])
if protoDeps != nil {
deps.Add(protoDeps)
}
attrs.Deps = bazel.MakeLabelListAttribute(deps)
return attrs