Merge branch 'master' of ssh://phabricator.internetapi.cn:2222/source/bdchain-grpc-api

This commit is contained in:
Nex 2018-10-09 13:49:44 +08:00
commit bb7804cb91
2 changed files with 35 additions and 4 deletions

24
Readme.md Normal file
View File

@ -0,0 +1,24 @@
# BDChain gRPC 指南
## 编译 Go 版本 gRPC
### 安装
- [Protocol Buffers 3](https://github.com/protocolbuffers/protobuf/releases)
- 下载对应版本,并将可执行程序 `protoc` 的目录加入到环境变量 `PATH`
- Go > 1.6
```bash
# 安装 Go 版本相关插件
go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/protoc-gen-go
```
参考资料:
- [Go Quick Start](https://grpc.io/docs/quickstart/go.html#prerequisites)
- [gRPC Go FAQ](https://github.com/grpc/grpc-go#faq)
### 编译
- 在本项目打开控制台,或者切换工作路径到本项目
- 执行 `gen`

15
gen.bat
View File

@ -1,9 +1,16 @@
@echo off @echo off
set dir=.\gen\go set dir=.\gen\go
set exe=protoc
set gen=protoc-gen-go
if defined GOPATH set PATH=%PATH%;%GOPATH%\bin
where /q %exe% || echo missing %exe% && exit /B
where /q %gen% || echo missing %gen% && exit /B
if not exist %dir% mkdir %dir% if not exist %dir% mkdir %dir%
protoc -I . --go_out=plugins=grpc:%dir% bdchain/api/common.proto %exe% -I . --go_out=plugins=grpc:%dir% bdchain/api/common.proto
protoc -I . --go_out=plugins=grpc:%dir% bdchain/api/tx_ledger.proto %exe% -I . --go_out=plugins=grpc:%dir% bdchain/api/tx_ledger.proto
protoc -I . --go_out=plugins=grpc:%dir% bdchain/api/ac_chain.proto %exe% -I . --go_out=plugins=grpc:%dir% bdchain/api/ac_chain.proto
echo All Done! echo all done