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