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 16set -ex 17 18cd "$(dirname "$0")/../../.." 19 20base=$(pwd) 21 22mkdir -p artifacts/ 23 24# All the ruby packages have been built in the artifact phase already 25# and we only collect them here to deliver them to the distribtest phase. 26cp -r "${EXTERNAL_GIT_ROOT}"/input_artifacts/ruby_native_gem_*/* artifacts/ || true 27 28well_known_protos=( any api compiler/plugin descriptor duration empty field_mask source_context struct timestamp type wrappers ) 29 30# TODO: all the artifact builder configurations generate a grpc-VERSION.gem 31# source distribution package, and only one of them will end up 32# in the artifacts/ directory. They should be all equivalent though. 33 34for arch in {x86,x64}; do 35 case $arch in 36 x64) 37 ruby_arch=x86_64 38 ;; 39 *) 40 ruby_arch=$arch 41 ;; 42 esac 43 for plat in {windows,linux,macos}; do 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 57done 58 59cd "$base/src/ruby/tools" 60gem build grpc-tools.gemspec 61cp ./grpc-tools*.gem "$base/artifacts/" 62