• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
34mkdir -p "third_party/cares/cares/cmake/build"
35pushd "third_party/cares/cares/cmake/build"
36cmake -DCMAKE_BUILD_TYPE=Release ../..
37make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
38popd
39
40# Install protobuf
41mkdir -p "third_party/protobuf/cmake/build"
42pushd "third_party/protobuf/cmake/build"
43cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -Dprotobuf_ABSL_PROVIDER=package ../..
44make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
45popd
46
47# Install re2 pkg-config using `make install`
48# because its `cmake install` doesn't install it
49# https://github.com/google/re2/issues/399
50pushd "third_party/re2"
51make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
52popd
53
54# Install re2
55mkdir -p "third_party/re2/cmake/build"
56pushd "third_party/re2/cmake/build"
57cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../..
58make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
59popd
60
61# Install zlib
62mkdir -p "third_party/zlib/cmake/build"
63pushd "third_party/zlib/cmake/build"
64cmake -DCMAKE_BUILD_TYPE=Release ../..
65make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
66popd
67
68# Install OpenTelemetry
69mkdir -p "third_party/opentelemetry-cpp/cmake/build"
70pushd "third_party/opentelemetry-cpp/cmake/build"
71cmake -DCMAKE_BUILD_TYPE=Release -DWITH_ABSEIL=ON -DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF ../..
72make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
73popd
74
75# Just before installing gRPC, wipe out contents of all the submodules to simulate
76# a standalone build from an archive.
77# Get list of submodules from the .gitmodules file since for "git submodule foreach"
78# we'd need to be in a git workspace (and that's not the case when running
79# distribtests as a bazel action)
80grep 'path = ' .gitmodules | sed 's/^.*path = //' | xargs rm -rf
81
82# Install gRPC
83# TODO(jtattermusch): avoid the need for setting utf8_range_DIR
84mkdir -p "cmake/build"
85pushd "cmake/build"
86cmake \
87  -DCMAKE_BUILD_TYPE=Release \
88  -DCMAKE_INSTALL_PREFIX=/usr/local/grpc \
89  -DgRPC_INSTALL=ON \
90  -DgRPC_BUILD_TESTS=OFF \
91  -DgRPC_ABSL_PROVIDER=package \
92  -DgRPC_CARES_PROVIDER=package \
93  -DgRPC_PROTOBUF_PROVIDER=package \
94  -Dutf8_range_DIR=/usr/local/lib/cmake/utf8_range \
95  -DgRPC_RE2_PROVIDER=package \
96  -DgRPC_SSL_PROVIDER=package \
97  -DgRPC_ZLIB_PROVIDER=package \
98  -DgRPC_BUILD_GRPCPP_OTEL_PLUGIN=ON \
99  ../..
100make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
101popd
102
103# Set pkgconfig envs
104export PKG_CONFIG_PATH=/usr/local/grpc/lib/pkgconfig
105export PATH=$PATH:/usr/local/grpc/bin
106
107# Show pkg-config configuration
108pkg-config --cflags grpc
109pkg-config --libs --static grpc
110pkg-config --cflags grpc++
111pkg-config --libs --static grpc++
112
113# Build helloworld example using Makefile and pkg-config
114pushd examples/cpp/helloworld
115make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}"
116popd
117
118# Build route_guide example using Makefile and pkg-config
119pushd examples/cpp/route_guide
120make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}"
121popd
122
123# Build otel example using Makefile and pkg-config
124pushd examples/cpp/otel/ostream
125make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}"
126popd
127