use well-known types with cc_proto_library and py_proto_library from protobuf.bzl

Viewed 186

I'd like to use google protobuf (master branch) + bazel v4.2.1 to set up communication between C++ and python parts of my program. I've got the following WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "com_google_protobuf",
    strip_prefix = "protobuf-master",
    urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

and the BUILD file:

load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")

cc_proto_library(
    name = "container_cc_proto",
    srcs = ["container.proto"],
    visibility = ["//visibility:public"],
    deps = ["@com_google_protobuf//:any_proto",],
)

py_proto_library(
    name = "container_py_proto",
    srcs = ["container.proto"],
    visibility = ["//visibility:public"],
    deps = ["@com_google_protobuf//:any_proto",],
)

The container.proto tries to include "google/protobuf/any.proto". On my command bazel build //:container_cc_proto I see the following error:

ERROR: /home/*user*/sandbox/bypass/BUILD:31:17: no such target '@com_google_protobuf//:any_proto_genproto': target 'any_proto_genproto' not declared in package '' defined by /home/*some path*/external/com_google_protobuf/BUILD and referenced by '//:container_cc_proto_genproto'

Could anyone please tell me how to include any.proto correctly, or any other known workarounds. Thanks!

0 Answers
Related