diff --git a/README.md b/README.md index d5a040f..972bc79 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,12 @@ go get -u google.golang.org/grpc 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}}` diff --git a/gen.bat b/gen-go.bat similarity index 100% rename from gen.bat rename to gen-go.bat diff --git a/gen.sh b/gen-go.sh similarity index 100% rename from gen.sh rename to gen-go.sh diff --git a/gen-web.bat b/gen-web.bat new file mode 100644 index 0000000..3d96dde --- /dev/null +++ b/gen-web.bat @@ -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 diff --git a/gen-web.sh b/gen-web.sh new file mode 100644 index 0000000..461d97a --- /dev/null +++ b/gen-web.sh @@ -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