Add web platform

This commit is contained in:
Nex 2018-10-31 15:31:46 +08:00
parent e402bf1ef2
commit e94f067e26
5 changed files with 29 additions and 1 deletions

View File

@ -12,6 +12,12 @@
go get -u google.golang.org/grpc go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/protoc-gen-go go get -u github.com/golang/protobuf/protoc-gen-go
``` ```
- Web
```bash
git clone https://github.com/grpc/grpc-web
cd grpc-web
sudo make install-plugin
```
参考资料: 参考资料:
@ -21,4 +27,4 @@
### 编译 ### 编译
- 在本项目打开控制台,或者切换工作路径到本项目 - 在本项目打开控制台,或者切换工作路径到本项目
- 执行 `./gen` - 执行 `./gen-{{platform}}`

View File

View File

15
gen-web.bat Normal file
View File

@ -0,0 +1,15 @@
@echo off
set dir=.\gen\web
set exe=protoc
set gen=protoc-protoc-gen-grpc-web
where /q %exe% || echo missing %exe% && exit /B
where /q %gen% || echo missing %gen% && exit /B
if not exist %dir% mkdir %dir%
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdchain/api/common.proto
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdchain/api/error_details.proto
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdchain/api/tx_ledger.proto
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdchain/api/ac_chain.proto
echo all done

7
gen-web.sh Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
dir=gen/web
mkdir -p $dir
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdchain/api/common.proto
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdchain/api/error_details.proto
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdchain/api/tx_ledger.proto
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdchain/api/ac_chain.proto