简体   繁体   English

从源代码构建 gRPC C++

[英]Building gRPC C++ from source

I am trying to build gRPC c++ from source from Build gRPC C++ I have already installed bazel.我想建立gRPC c++从源构建GRPC C ++我已经安装了巴泽尔。 Though when I tried to build I am seeing following error.虽然当我尝试构建时,我看到了以下错误。

$ 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)

Could someone point what I am missing here.有人可以指出我在这里缺少什么。

When I tried to run bazel info , I am getting following error.当我尝试运行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

Though bazel --version shows as bazel 2.0.0 .虽然bazel --version显示为bazel 2.0.0

$ bazel --version
bazel 2.0.0

The latest commit of gRPC is 9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14 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

The commit of grpc you are trying to build is not compatible with the version of bazel you have installed (2.0.0).您尝试构建的 grpc 提交与您安装的 bazel 版本(2.0.0)不兼容。

The commit 9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14 is quite old (15 April 19), where the HEAD of that repo (at the time of writing this) is at eba60d8dbe4099c34b8097b2c89998d4484740ac , which now in BUILDING.md shows you need at least version 1.0.0 (there is a bazel wrapper at tools/bazel that will intercept and use 1.0.0 anyway)提交9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14是很老(19年4月15日),其中该回购的HEAD(在写这篇的时间)是eba60d8dbe4099c34b8097b2c89998d4484740ac ,现在在BUILDING.md节目至少需要1.0.0版本(还有一个巴泽尔无论如何都会拦截并使用 1.0.0 的tools/bazel包装器)

For your specific commit however, trying different versions, I was able to build :all label with bazel version 0.20.0但是,对于您的特定提交,尝试不同的版本,我能够使用 bazel 版本0.20.0构建:all标签

I'd recommend trying bazelisk .我建议尝试bazelisk You can add it to your PATH, add a .bazelversion file to the repository and bazelisk will take care of downloading the required bazel version.您可以将它添加到您的 PATH,将.bazelversion文件添加到存储库,bazelisk 将负责下载所需的 bazel 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM