xref: /aosp_15_r20/external/grpc-grpc/src/ruby/nativedebug/build_package.sh (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1#!/bin/bash
2# Copyright 2023 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
20PLATFORM="$1"
21if [[ "$PLATFORM" == "" ]]; then
22  echo "first argument must be a ruby gem platform"
23  exit 1
24fi
25
26if ! test -d symbols; then
27  echo "directory $(pwd)/symbols should exist and be populated with .dbg symbolf files before running this script"
28  exit 1
29fi
30for f in "$(ls symbols)"; do
31  echo "checking symbol file: $f"
32  if [[ "$f" != *.dbg ]]; then
33    echo "symbol file names should end in .dbg"
34    exit 1
35  fi
36done
37
38rm -r tmp || true
39rm -r pkg || true
40mkdir -p tmp
41mkdir -p pkg
42
43# we need to generate some package contents dynamically
44cp -p grpc-native-debug.gemspec tmp
45cp -p README.md tmp
46cp -p version.rb tmp
47cp -p platform.rb tmp
48sed -i "s/# GENERATED BY BUILD_PACKAGES SCRIPT/'${PLATFORM}'/" tmp/platform.rb
49mkdir -p tmp/symbols
50cp -p symbols/*"$PLATFORM"*.dbg tmp/symbols
51
52# build
53cd tmp
54gem build grpc-native-debug.gemspec
55cp grpc-native-debug*.gem ../pkg
56