为Kratos prtobuf文件添加多种编译输出

Csharp 安装Grpc.tools https://www.nuget.org/packages/Grpc.Tools/ 下载解压 nupkg文件(改扩展名为zip),也可以使用附件的7z包 解压 找到tools中对应系统架构的软件,设置下环境变量,让系统可以找到就行。 Linux 需要创建一个符号链接 ln -s `which grpc_csharp_plugin` /usr/bin/protoc-gen-grpc-csharp 修改Kratos项目的Make文件 在api这个make任务中添加下面内容 --csharp_out=./api/pipe/v1 \ --grpc-csharp_out=./api/pipe/v1 \ 完整内容为 .PHONY: api # generate api proto api: protoc --proto_path=./api \ --proto_path=./third_party \ --go_out=paths=source_relative:./api \ --go-http_out=paths=source_relative:./api \ --go-grpc_out=paths=source_relative:./api \ --csharp_out=./api/pipe/v1 \ --grpc-csharp_out=./api/pipe/v1 \ --openapi_out==paths=source_relative:. \ 参考 https://github.com/grpc/grpc/blob/master/src/csharp/BUILD-INTEGRATION.md 📎tools.7z Python 安装必要包 pip install grpclib protobuf 查询路径 which protoc-gen-grpclib_python 或者 which protoc-gen-python_grpc我这里返回信息如下: ➜ czyt which protoc-gen-grpclib_python /usr/sbin/protoc-gen-grpclib_python 如法炮制,创建软链接 ln -s /usr/sbin/protoc-gen-grpclib_python /usr/sbin/protoc-gen-grpc_python 修改Makefile 添加下面的内容,再执行make api生成api即可。 --python_out=....

April 8, 2022 · 1 min · czyt