build_artifact_ruby.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. # the platform for which we wanna build the native gem
  17. GEM_PLATFORM="$1"
  18. SYSTEM=$(uname | cut -f 1 -d_)
  19. cd "$(dirname "$0")/../../.."
  20. if [ "$SYSTEM" == "MSYS" ] ; then
  21. SYSTEM=MINGW32
  22. fi
  23. if [ "$SYSTEM" == "MINGW64" ] ; then
  24. SYSTEM=MINGW32
  25. fi
  26. if [ "$SYSTEM" == "MINGW32" ] ; then
  27. echo "Need Linux to build the Windows ruby gem."
  28. exit 1
  29. fi
  30. # log ruby version for easier debugging if things go wrong
  31. # we assume that the current ruby version has already been selected
  32. # (e.g. by the top-level CI script or with rvm locally)
  33. ruby --version
  34. # log gem versions for easier debugging if things go wrong
  35. gem list || true
  36. # avoid polluting the global gem diretory
  37. # by configuring "bundle install" to install all the gems
  38. # into a project-local directory
  39. export BUNDLE_PATH=bundle_local_gems
  40. tools/run_tests/helper_scripts/bundle_install_wrapper.sh
  41. # set the dockerhub org under which all the gRPC's ruby-compiler-dock docker images
  42. # are available.
  43. export DOCKERHUB_ORGANIZATION=grpctesting
  44. bundle exec rake "gem:native[${GEM_PLATFORM}]"
  45. if [ "$SYSTEM" == "Darwin" ] ; then
  46. # TODO: consider rewriting this to pass shellcheck
  47. # shellcheck disable=SC2046,SC2010
  48. rm $(ls pkg/*.gem | grep -v darwin)
  49. fi
  50. mkdir -p "${ARTIFACTS_OUT}"
  51. cp pkg/*.gem "${ARTIFACTS_OUT}"/