xref: /aosp_15_r20/external/grpc-grpc/test/distrib/cpp/run_distrib_test_cmake.sh (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1#!/bin/bash
2# Copyright 2017 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
20# Install openssl (to use instead of boringssl)
21apt-get update && apt-get install -y libssl-dev
22
23# Use externally provided env to determine build parallelism, otherwise use default.
24GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS=${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS:-4}
25
26# Install absl
27mkdir -p "third_party/abseil-cpp/cmake/build"
28pushd "third_party/abseil-cpp/cmake/build"
29cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../..
30make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
31popd
32
33# Install c-ares
34# If the distribution provides a new-enough version of c-ares,
35# this section can be replaced with:
36# apt-get install -y libc-ares-dev
37mkdir -p "third_party/cares/cares/cmake/build"
38pushd "third_party/cares/cares/cmake/build"
39cmake -DCMAKE_BUILD_TYPE=Release ../..
40make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
41popd
42
43# Install protobuf
44mkdir -p "third_party/protobuf/cmake/build"
45pushd "third_party/protobuf/cmake/build"
46cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -Dprotobuf_ABSL_PROVIDER=package ../..
47make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
48popd
49
50# Install re2
51mkdir -p "third_party/re2/cmake/build"
52pushd "third_party/re2/cmake/build"
53cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../..
54make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
55popd
56
57# Install zlib
58mkdir -p "third_party/zlib/cmake/build"
59pushd "third_party/zlib/cmake/build"
60cmake -DCMAKE_BUILD_TYPE=Release ../..
61make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
62popd
63
64# Just before installing gRPC, wipe out contents of all the submodules to simulate
65# a standalone build from an archive.
66# Get list of submodules from the .gitmodules file since for running "git submodule foreach"
67# we'd need to be in a git workspace (and that's not the case when running
68# distribtests as a bazel action)
69grep 'path = ' .gitmodules | sed 's/^.*path = //' | xargs rm -rf
70
71# Install gRPC
72mkdir -p "cmake/build"
73pushd "cmake/build"
74cmake \
75  -DCMAKE_BUILD_TYPE=Release \
76  -DgRPC_INSTALL=ON \
77  -DgRPC_BUILD_TESTS=OFF \
78  -DgRPC_CARES_PROVIDER=package \
79  -DgRPC_ABSL_PROVIDER=package \
80  -DgRPC_PROTOBUF_PROVIDER=package \
81  -DgRPC_RE2_PROVIDER=package \
82  -DgRPC_SSL_PROVIDER=package \
83  -DgRPC_ZLIB_PROVIDER=package \
84  ../..
85make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
86popd
87
88# Build helloworld example using cmake
89mkdir -p "examples/cpp/helloworld/cmake/build"
90pushd "examples/cpp/helloworld/cmake/build"
91cmake ../..
92make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}"
93popd
94