$ git clone -b RELEASE_TAG_HERE https://github.com/grpc/grpc $ cd grpc $ git submodule update --init
如果速度慢,改.gitmodules
[submodule "third_party/zlib"] path = third_party/zlib url = https://github.com.cnpmjs.org/madler/zlib.git # When using CMake to build, the zlib submodule ends up with a # generated file that makes Git consider the submodule dirty. This # state can be ignored for day-to-day development on gRPC. ignore = dirty [submodule "third_party/protobuf"] path = third_party/protobuf url = https://github.com.cnpmjs.org/protocolbuffers/protobuf.git [submodule "third_party/googletest"] path = third_party/googletest url = https://github.com.cnpmjs.org/google/googletest.git [submodule "third_party/benchmark"] path = third_party/benchmark url = https://hub.fastgit.org/google/benchmark.git [submodule "third_party/boringssl-with-bazel"] path = third_party/boringssl-with-bazel url = https://github.com.cnpmjs.org/google/boringssl.git [submodule "third_party/re2"] path = third_party/re2 url = https://github.com/google/re2.git [submodule "third_party/cares/cares"] path = third_party/cares/cares url = https://github.com.cnpmjs.org/c-ares/c-ares.gite branch = cares-1_12_0 [submodule "third_party/bloaty"] path = third_party/bloaty url = https://github.com.cnpmjs.org/google/bloaty.git [submodule "third_party/abseil-cpp"] path = third_party/abseil-cpp url = https://github.com/abseil/abseil-cpp.git branch = lts_2020_02_25 [submodule "third_party/envoy-api"] path = third_party/envoy-api url = https://github.com/envoyproxy/data-plane-api.git [submodule "third_party/googleapis"] path = third_party/googleapis url = https://github.com/googleapis/googleapis.git [submodule "third_party/protoc-gen-validate"] path = third_party/protoc-gen-validate url = https://github.com.cnpmjs.org/envoyproxy/protoc-gen-validate.git [submodule "third_party/libuv"] path = third_party/libuv url = https://github.com.cnpmjs.org/libuv/libuv.git [submodule "third_party/opencensus-proto"] path = third_party/opencensus-proto url = https://github.com/census-instrumentation/opencensus-proto.git [submodule "third_party/opentelemetry"] path = third_party/opentelemetry url = https://hub.fastgit.org/open-telemetry/opentelemetry-proto.git [submodule "third_party/xds"] path = third_party/xds url = https://github.com.cnpmjs.org/cncf/xds.git
再执行 git submodule sync
$ mkdir -p cmake/build $ cd cmake/build $ cmake ../.. $ make
If you are building gRPC < 1.27 or if you are using CMake < 3.13 you will need to select "package" mode (rather than "module" mode) for the dependencies
$ cmake ../.. -DgRPC_INSTALL=ON \
-DCMAKE_BUILD_TYPE=Release \
-DgRPC_ABSL_PROVIDER=package \
-DgRPC_CARES_PROVIDER=package \
-DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_RE2_PROVIDER=package \
-DgRPC_SSL_PROVIDER=package \
-DgRPC_ZLIB_PROVIDER=package
或者
cmake ../.. -DgRPC_INSTALL=ON \
-DCMAKE_BUILD_TYPE=Release \
-DgRPC_ABSL_PROVIDER=module \
-DgRPC_CARES_PROVIDER=module \
-DgRPC_PROTOBUF_PROVIDER=module \
-DgRPC_RE2_PROVIDER=module \
-DgRPC_SSL_PROVIDER=module \
-DgRPC_ZLIB_PROVIDER=module
$ make
$ make install