Debian Codegraph @

tools/run_tests/artifacts/build_package_ruby.sh

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