没有这样的目标'//external:protocol_compiler':当我使用bzlmod编译proto时未声明目标'protocol_compiler'

问题描述 投票:0回答:1

模块.bazel

module(
  name = "proto_test"
)

bazel_dep(name = "grpc", version = "1.41.0", repo_name = "com_github_grpc_grpc")

构建:

load("@com_github_grpc_grpc//bazel:grpc_build_system.bzl", "grpc_proto_library")

grpc_proto_library(
    name = "rpc_proto",
    srcs = [
        "rpc.proto"
    ],
    use_external = True,
)

当我运行命令时,发生错误,我该怎么办,谢谢您的帮助!

bazel build :rpc_proto
ERROR: /tmp/BUILD:3:19: every rule of type _generate_cc implicitly depends upon the target '//external:protocol_compiler', but this target could not be found because of: no such target '//external:protocol_compiler': target 'protocol_compiler' not declared in package 'external' defined by /tmp/WORKSPACE (Tip: use `query "//external:*"` to see all the targets in that package)
protocol-buffers grpc bazel bzlmod
1个回答
0
投票

gRPC 目前不支持 Bazel 模块构建(1.41.0 是一个非常古老的版本)。您应该设置常用的 Bazel 构建并使用更新的 gRPC 版本。请参阅此链接

http_archive(
    name = "com_github_grpc_grpc",
    urls = [
        "https://github.com/grpc/grpc/archive/YOUR_GRPC_COMMIT_SHA.tar.gz",
    ],
    strip_prefix = "grpc-YOUR_GRPC_COMMIT_SHA",
)
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()
© www.soinside.com 2019 - 2024. All rights reserved.