generate.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. ## Copyright 2024, gRPC Authors All rights reserved.
  3. ##
  4. ## Licensed under the Apache License, Version 2.0 (the "License");
  5. ## you may not use this file except in compliance with the License.
  6. ## You may obtain a copy of the License at
  7. ##
  8. ## http://www.apache.org/licenses/LICENSE-2.0
  9. ##
  10. ## Unless required by applicable law or agreed to in writing, software
  11. ## distributed under the License is distributed on an "AS IS" BASIS,
  12. ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. ## See the License for the specific language governing permissions and
  14. ## limitations under the License.
  15. set -eu
  16. here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  17. root="$here/../.."
  18. protoc=$(which protoc)
  19. function invoke_protoc {
  20. # Setting -x when running the script produces a lot of output, instead boil
  21. # just echo out the protoc invocations.
  22. echo "$protoc" "$@"
  23. "$protoc" "$@"
  24. }
  25. #- DESCRIPTOR SETS ------------------------------------------------------------
  26. function generate_test_service_descriptor_set {
  27. local proto proto_path output
  28. proto="$here/local/test-service.proto"
  29. proto_path="$(dirname "$proto")"
  30. output="$root/Tests/GRPCProtobufCodeGenTests/Generated/test-service.pb"
  31. invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" --include_source_info
  32. }
  33. function generate_foo_service_descriptor_set {
  34. local proto proto_path output
  35. proto="$here/local/foo-service.proto"
  36. proto_path="$(dirname "$proto")"
  37. output="$root/Tests/GRPCProtobufCodeGenTests/Generated/foo-service.pb"
  38. invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
  39. --include_source_info \
  40. --include_imports
  41. }
  42. function generate_bar_service_descriptor_set {
  43. local proto proto_path output
  44. proto="$here/local/bar-service.proto"
  45. proto_path="$(dirname "$proto")"
  46. output="$root/Tests/GRPCProtobufCodeGenTests/Generated/bar-service.pb"
  47. invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
  48. --include_source_info \
  49. --include_imports
  50. }
  51. #------------------------------------------------------------------------------
  52. # Descriptor sets
  53. generate_test_service_descriptor_set
  54. generate_foo_service_descriptor_set
  55. generate_bar_service_descriptor_set