我需要什么样的Bazel咒语才能包含gRPC反射头文件



当我试图编译一个使用gRPC反射的bazel项目时,我会得到以下错误。

fatal error: external/com_github_grpc_grpc/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h: No such file or directory

在我的工作空间中,我有以下绑定:

def _com_github_grpc_grpc():
external_http_archive("com_github_grpc_grpc")
external_http_archive("build_bazel_rules_apple")
# Rebind some stuff to match what the gRPC Bazel is expecting.
native.bind(
name = "protobuf_headers",
actual = "@com_google_protobuf//:protobuf_headers",
)
native.bind(
name = "libssl",
actual = "//external:ssl",
)
native.bind(
name = "cares",
actual = "//external:ares",
)
native.bind(
name = "grpc",
actual = "@com_github_grpc_grpc//:grpc++",
)

在我的BUILD文件中,我有以下deps:

deps = [
"//external:protobuf_headers",
"//external:grpc",
],

我还需要什么额外的咒语才能包含在问题的顶部?

在深入研究问题后,我发现我需要以下WORKSPACE

workspace(name = "xxx")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_github_grpc_grpc",
strip_prefix = "grpc-master",
urls = ["https://github.com/grpc/grpc/archive/master.tar.gz"],
)
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()

以及以下构建:

cc_binary(
name = "ReflectionPlay",
copts = ["-std=c++17"],
srcs = ["reflection_play.cc"],
deps = [
"@com_github_grpc_grpc//:grpc++",
"@com_github_grpc_grpc//:grpc++_reflection",
"@com_github_grpc_grpc//:grpcpp_admin",
],
)

最新更新