让gRPC源码下得飞起

一、遇到的问题

按照github上的说明进行操作

grpc/BUILDING.md at master · grpc/grpc

Unix
 $ git clone -b v1.28.0-pre3 https://github.com/grpc/grpc
 $ cd grpc
 $ git submodule update --init

克隆最新release版本v1.28.0-pre3,但是克隆速度巨慢。

二、解决办法

通过码云导入github地址之后克隆速度显著提升。

我已经将https://github.com/grpc/grpc导入我的码云仓库,可以直接克隆。

git clone https://gitee.com/chenwr2020/grpc.git 
git checkout -b grpc_v1.28.0-pre3 v1.28.0-pre3

克隆完毕之后再切换release版本tag分支,具体可以根据实际需求来选择分支。

在grpc目录下打开.gitmodules,默认为:

[submodule "third_party/zlib"]
    path = third_party/zlib
    url = https://github.com/madler/zlib
    # 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/google/protobuf.git
    branch = 3.0.x
[submodule "third_party/gflags"]
    path = third_party/gflags
    url = https://github.com/gflags/gflags.git
[submodule "third_party/googletest"]
    path = third_party/googletest
    url = https://github.com/google/googletest.git
[submodule "third_party/benchmark"]
    path = third_party/benchmark
    url = https://github.com/google/benchmark
[submodule "third_party/boringssl-with-bazel"]
    path = third_party/boringssl-with-bazel
    url = https://github.com/google/boringssl.git
[submodule "third_party/cares/cares"]
    path = third_party/cares/cares
    url = https://github.com/c-ares/c-ares.git
    branch = cares-1_12_0
[submodule "third_party/bloaty"]
    path = third_party/bloaty
    url = https://github.com/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/envoyproxy/protoc-gen-validate.git
[submodule "third_party/udpa"]
    path = third_party/udpa
    url = https://github.com/cncf/udpa.git
[submodule "third_party/libuv"]
    path = third_party/libuv
    url = https://github.com/libuv/libuv.git

修改为

[submodule "third_party/zlib"]
	path = third_party/zlib
	url = https://gitee.com/chenwr2020/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://gitee.com/chenwr2020/protobuf.git
	branch = 3.0.x
[submodule "third_party/gflags"]
	path = third_party/gflags
	url = https://gitee.com/chenwr2020/gflags.git
[submodule "third_party/googletest"]
	path = third_party/googletest
	url = https://gitee.com/chenwr2020/googletest.git
[submodule "third_party/benchmark"]
	path = third_party/benchmark
	url = https://gitee.com/chenwr2020/benchmark.git
[submodule "third_party/boringssl-with-bazel"]
	path = third_party/boringssl-with-bazel
	url = https://gitee.com/chenwr2020/boringssl.git
[submodule "third_party/cares/cares"]
	path = third_party/cares/cares
	url = https://gitee.com/chenwr2020/c-ares.git
	branch = cares-1_12_0
[submodule "third_party/bloaty"]
	path = third_party/bloaty
	url = https://gitee.com/chenwr2020/bloaty.git
[submodule "third_party/abseil-cpp"]
	path = third_party/abseil-cpp
	url = https://gitee.com/chenwr2020/abseil-cpp.git
	branch = lts_2020_02_25
[submodule "third_party/envoy-api"]
	path = third_party/envoy-api
	url = https://gitee.com/chenwr2020/data-plane-api.git
[submodule "third_party/googleapis"]
	path = third_party/googleapis
	url = https://gitee.com/chenwr2020/googleapis.git
[submodule "third_party/protoc-gen-validate"]
	path = third_party/protoc-gen-validate
	url = https://gitee.com/chenwr2020/protoc-gen-validate.git
[submodule "third_party/udpa"]
	path = third_party/udpa
	url = https://gitee.com/chenwr2020/udpa.git
[submodule "third_party/libuv"]
	path = third_party/libuv
	url = https://gitee.com/chenwr2020/libuv.git

git submodule update --init 会克隆一些子模块仓库。自动安装这些第三方模块仓库还是很慢,我已经将第三方模块的仓库都导入我的码云仓库。


速度提升不止一个档次。

三、码云导入github

登录码云注册账号。


导入成功后

之后克隆显示需要添加公钥。

在你要添加的机器中获取自己原先github生成的密钥。
具体如何生成可以参考博客:
ubuntu14.04 Git Github环境搭建设置_chenwr2018的博客-CSDN博客

将上述文件获取的内容复制粘贴后生成公钥。


到此就可以愉快的克隆了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章