Solve dependency issue when using gRPC cpp in bazel

[亡魂溺海] 提交于 2021-01-04 07:14:48

问题


I am trying to run a simple program with gRPC in dependency. I tried several examples but continuesly get the following error:

ERROR: /home/git/examples/WORKSPACE:1:1: name 'git_repository' is not defined
ERROR: Error evaluating WORKSPACE file

This is my bazel version:

➜ git:(master) ✗ bazel version
Build label: 0.23.2

And this is the workspace file content:

git_repository(
    name = "com_github_grpc_grpc",
    commit = "ac0808b107d73613191b66617a547a201871a845",
    remote = "https://github.com/grpc/grpc.git",
)

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

grpc_deps()

bind(
    name = "grpc_cpp_plugin",
    actual = "@com_github_grpc_grpc//:grpc_cpp_plugin",
)

bind(
    name = "grpc++_codegen_proto",
    actual = "@com_github_grpc_grpc//:grpc++_codegen_proto",
)

Any help will be appreciated!


回答1:


git_repository is no longer a native rule. You need to include it at the top of your WORKSPACE with:

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")


来源:https://stackoverflow.com/questions/55190124/solve-dependency-issue-when-using-grpc-cpp-in-bazel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!