ToB企服应用市场:ToB评测及商务社交产业平台

标题: 第22篇 天生proto文件bat脚本 [打印本页]

作者: 泉缘泉    时间: 2024-9-13 17:41
标题: 第22篇 天生proto文件bat脚本
1.天生单个Proto.bat内容

  1. @rem Copyright 2016, Google Inc.
  2. @rem All rights reserved.
  3. @rem
  4. @rem Redistribution and use in source and binary forms, with or without
  5. @rem modification, are permitted provided that the following conditions are
  6. @rem met:
  7. @rem
  8. @rem     * Redistributions of source code must retain the above copyright
  9. @rem notice, this list of conditions and the following disclaimer.
  10. @rem     * Redistributions in binary form must reproduce the above
  11. @rem copyright notice, this list of conditions and the following disclaimer
  12. @rem in the documentation and/or other materials provided with the
  13. @rem distribution.
  14. @rem     * Neither the name of Google Inc. nor the names of its
  15. @rem contributors may be used to endorse or promote products derived from
  16. @rem this software without specific prior written permission.
  17. @rem
  18. @rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. @rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. @rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. @rem A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. @rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. @rem SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. @rem LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. @rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. @rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. @rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. @rem Generate the C# code for .proto files
  30. setlocal
  31. @rem enter this directory
  32. cd /d %~dp0
  33. set TOOLS_PATH=tools
  34. set /p PROTO_FILE_NAME=input proto filename:
  35. %TOOLS_PATH%\protoc.exe -I./protos --csharp_out ./code --grpc_out ./code ./protos/%PROTO_FILE_NAME%.proto --plugin=protoc-gen-grpc=%TOOLS_PATH%\grpc_csharp_plugin.exe
  36. pause
复制代码
这个脚本是一个批处理文件(.bat 文件),其作用是使用 protoc.exe 工具天生 C# 代码和 gRPC 服务代码,基于指定的 .proto 文件。以下是对脚本的逐步解释:

总结

这个批处理脚本的作用是:当用户输入 .proto 文件名后,使用 protoc.exe 和 gRPC 插件天生相应的 C# 和 gRPC 代码,并将它们保存到 ./code 目录下。
=================================================================================================

2.批量天生Protos.bat

  1. @rem Copyright 2016, Google Inc.
  2. @rem All rights reserved.
  3. @rem
  4. @rem Redistribution and use in source and binary forms, with or without
  5. @rem modification, are permitted provided that the following conditions are
  6. @rem met:
  7. @rem
  8. @rem     * Redistributions of source code must retain the above copyright
  9. @rem notice, this list of conditions and the following disclaimer.
  10. @rem     * Redistributions in binary form must reproduce the above
  11. @rem copyright notice, this list of conditions and the following disclaimer
  12. @rem in the documentation and/or other materials provided with the
  13. @rem distribution.
  14. @rem     * Neither the name of Google Inc. nor the names of its
  15. @rem contributors may be used to endorse or promote products derived from
  16. @rem this software without specific prior written permission.
  17. @rem
  18. @rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. @rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. @rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. @rem A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. @rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. @rem SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. @rem LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. @rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. @rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. @rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. @rem Generate the C# code for .proto files
  30. setlocal
  31. @rem enter this directory
  32. cd /d %~dp0
  33. set TOOLS_PATH=tools
  34. for %%a in (protos/*.proto) do %TOOLS_PATH%\protoc.exe -I./protos --csharp_out ./code --grpc_out ./code ./protos/%%a --plugin=protoc-gen-grpc=%TOOLS_PATH%\grpc_csharp_plugin.exe
  35. pause
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4