From c768102bce5d64f93559a75783edb5509669f58c Mon Sep 17 00:00:00 2001 From: Sam Delmerico Date: Fri, 4 Feb 2022 21:01:20 +0000 Subject: 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 --- java/java.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index e55f04599..d0f0abc7a 100644 --- a/java/java.go +++ b/java/java.go @@ -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 -- cgit v1.2.3-59-g8ed1b