build_package_ruby.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # Copyright 2016 gRPC authors.
  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 -ex
  16. cd "$(dirname "$0")/../../.."
  17. base=$(pwd)
  18. mkdir -p artifacts/
  19. # All the "grpc" gems have been built in the artifact phase already
  20. # and we only collect them here to deliver them to the distribtest phase.
  21. # NOTE: Besides the platform-specific native gems, all the artifact build
  22. # jobs will generate a grpc-X.Y.Z.gem source package, and only one of them
  23. # will end up in the artifacts/ directory. They should be all equivalent
  24. # though.
  25. cp -r "${EXTERNAL_GIT_ROOT}"/input_artifacts/ruby_native_gem_*/* artifacts/ || true
  26. # Next, build the "grpc-tools" gem by collecting the protoc and grpc_ruby_plugin binaries
  27. # that have been built by the the artifact build phase previously.
  28. well_known_protos=( any api compiler/plugin descriptor duration empty field_mask source_context struct timestamp type wrappers )
  29. for arch in {x86,x64}; do
  30. case $arch in
  31. x64)
  32. ruby_arch=x86_64
  33. ;;
  34. *)
  35. ruby_arch=$arch
  36. ;;
  37. esac
  38. for plat in {windows,linux,macos}; do
  39. # skip non-existent macos x86 protoc artifact
  40. if [[ "${plat}_${arch}" == "macos_x86" ]]
  41. then
  42. continue
  43. fi
  44. input_dir="${EXTERNAL_GIT_ROOT}/input_artifacts/protoc_${plat}_${arch}"
  45. output_dir="$base/src/ruby/tools/bin/${ruby_arch}-${plat}"
  46. mkdir -p "$output_dir"/google/protobuf
  47. mkdir -p "$output_dir"/google/protobuf/compiler # needed for plugin.proto
  48. cp "$input_dir"/protoc* "$input_dir"/grpc_ruby_plugin* "$output_dir/"
  49. if [[ "$plat" != "windows" ]]
  50. then
  51. chmod +x "$output_dir/protoc" "$output_dir/grpc_ruby_plugin"
  52. fi
  53. for proto in "${well_known_protos[@]}"; do
  54. cp "$base/third_party/protobuf/src/google/protobuf/$proto.proto" "$output_dir/google/protobuf/$proto.proto"
  55. done
  56. done
  57. done
  58. cd "$base/src/ruby/tools"
  59. gem build grpc-tools.gemspec
  60. cp ./grpc-tools*.gem "$base/artifacts/"