【问题标题】:Building gRPC C++ from source从源代码构建 gRPC C++
【发布时间】:2020-01-20 00:11:07
【问题描述】:

我正在尝试从Build gRPC C++ 的源代码构建gRPC c++ 我已经安装了 bazel。 虽然当我尝试构建时,我看到了以下错误。

$ bazel build :all
Starting local Bazel server and connecting to it...
ERROR: /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/io_bazel_rules_python/python/pip.bzl:39:25: Traceback (most recent 
call last):
        File "/home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/io_bazel_rules_python/python/pip.bzl", line 37
                repository_rule(<2 more arguments>)
        File "/home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/io_bazel_rules_python/python/pip.bzl", line 39, in repositor
y_rule
                attr.label(allow_files = True, <2 more arguments>)
'single_file' is no longer supported. use allow_single_file instead. You can use --incompatible_disable_deprecated_attr_params=false to temporarily disable th
is check.
ERROR: error loading package '': Extension file 'python/pip.bzl' has errors
ERROR: error loading package '': Extension file 'python/pip.bzl' has errors
INFO: Elapsed time: 7.505s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

有人可以指出我在这里缺少什么。

当我尝试运行 bazel info 时,出现以下错误。

$ bazel info --incompatible_disable_deprecated_attr_params=false
ERROR: /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl:771:21: name 'FileType' is not defined
ERROR: error loading package '': in /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/org_pubref_rules_protobuf/python/rules.bzl: in /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/org_pubref_rules_protobuf/cpp/rules.bzl: in /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/org_pubref_rules_protobuf/protobuf/rules.bzl: Extension 'protobuf/internal/proto_compile.bzl' has errors

虽然bazel --version 显示为bazel 2.0.0

$ bazel --version
bazel 2.0.0

gRPC 的最新提交是9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14

$ git log -1
commit 9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14 (HEAD, tag: v1.20.0)
Merge: 1b488f8361 ae72bf76b3
Author: Lidi Zheng <scallopsky@gmail.com>
Date:   Mon Apr 15 15:38:24 2019 -0700

    Merge pull request #18760 from lidizheng/v1.20.x

    Bump version to v1.20.0

【问题讨论】:

  • 你在这里使用的是什么版本的 bazel? bazel info 会提供一些很好的信息。 grpc 的提交 sha 在这里也会有帮助。
  • 我正在使用bazel 2.0.0。 grpc 的 commit sha 为9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14。我也无法运行bazel info。我用运行 bazel info 时遇到的错误更新了我的帖子。

标签: c++ grpc bazel


【解决方案1】:

您尝试构建的 grpc 提交与您安装的 bazel 版本(2.0.0)不兼容。

提交9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14 相当旧(19 年 4 月 15 日),该 repo 的 HEAD(在撰写本文时)位于 eba60d8dbe4099c34b8097b2c89998d4484740ac,现在在 BUILDING.md 中显示您至少需要 1.0 版.0(tools/bazel 有一个 bazel 包装器,无论如何都会拦截并使用 1.0.0)

但是,对于您的特定提交,尝试不同的版本,我能够使用 bazel 版本 0.20.0 构建 :all 标签

我建议尝试bazelisk。您可以将其添加到您的 PATH,将 .bazelversion 文件添加到存储库中,bazelisk 将负责下载所需的 bazel 版本。

【讨论】:

  • 当我将我的 HEAD 指向 eba60d8dbe4099c34b8097b2c89998d4484740ac 时,我就可以构建了。谢谢你。稍后我会尝试bazelisk
猜你喜欢
  • 2018-11-25
  • 1970-01-01
  • 2013-06-01
  • 2012-12-11
  • 2015-08-20
  • 2011-09-05
  • 2020-06-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多