diff options
| author | 2022-05-31 19:22:32 +0000 | |
|---|---|---|
| committer | 2022-05-31 19:22:32 +0000 | |
| commit | 5317be265af74419c1e903e8e0d56b1e957e8069 (patch) | |
| tree | b832e462073443f8ba86001a95b6e6e09f85441e /python/python.go | |
| parent | ced67ded0b9b962c575989c1835ebe9d9b776d50 (diff) | |
| parent | 53b62098d04b2ca4465d9f4954ff521320ad4310 (diff) | |
Merge "Add bp2build converter for python protobuf files"
Diffstat (limited to 'python/python.go')
| -rw-r--r-- | python/python.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/python/python.go b/python/python.go index b100cc318..7e4cb837c 100644 --- a/python/python.go +++ b/python/python.go @@ -207,6 +207,29 @@ func (m *Module) makeArchVariantBaseAttributes(ctx android.TopDownMutatorContext } } } + + partitionedSrcs := bazel.PartitionLabelListAttribute(ctx, &attrs.Srcs, bazel.LabelPartitions{ + "proto": android.ProtoSrcLabelPartition, + "py": bazel.LabelPartition{Keep_remainder: true}, + }) + attrs.Srcs = partitionedSrcs["py"] + + if !partitionedSrcs["proto"].IsEmpty() { + protoInfo, _ := android.Bp2buildProtoProperties(ctx, &m.ModuleBase, partitionedSrcs["proto"]) + protoLabel := bazel.Label{Label: ":" + protoInfo.Name} + + pyProtoLibraryName := m.Name() + "_py_proto" + ctx.CreateBazelTargetModule(bazel.BazelTargetModuleProperties{ + Rule_class: "py_proto_library", + Bzl_load_location: "//build/bazel/rules/python:py_proto.bzl", + }, android.CommonAttributes{ + Name: pyProtoLibraryName, + }, &bazelPythonProtoLibraryAttributes{ + Deps: bazel.MakeSingleLabelListAttribute(protoLabel), + }) + + attrs.Deps.Add(bazel.MakeLabelAttribute(":" + pyProtoLibraryName)) + } return attrs } |