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# Just before installing gRPC, wipe out contents of all the submodules to simulate 69# a standalone build from an archive 70# shellcheck disable=SC2016 71git submodule foreach 'cd $toplevel; rm -rf $name' 72 73# Install gRPC 74# TODO(jtattermusch): avoid the need for setting utf8_range_DIR 75mkdir -p "cmake/build" 76pushd "cmake/build" 77cmake \ 78 -DCMAKE_BUILD_TYPE=Release \ 79 -DCMAKE_INSTALL_PREFIX=/usr/local/grpc \ 80 -DgRPC_INSTALL=ON \ 81 -DgRPC_BUILD_TESTS=OFF \ 82 -DgRPC_ABSL_PROVIDER=package \ 83 -DgRPC_CARES_PROVIDER=package \ 84 -DgRPC_PROTOBUF_PROVIDER=package \ 85 -Dutf8_range_DIR=/usr/local/lib/cmake/utf8_range \ 86 -DgRPC_RE2_PROVIDER=package \ 87 -DgRPC_SSL_PROVIDER=package \ 88 -DgRPC_ZLIB_PROVIDER=package \ 89 ../.. 90make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install 91popd 92 93# Set pkgconfig envs 94export PKG_CONFIG_PATH=/usr/local/grpc/lib/pkgconfig 95export PATH=$PATH:/usr/local/grpc/bin 96 97# Show pkg-config configuration 98pkg-config --cflags grpc 99pkg-config --libs --static grpc 100pkg-config --cflags grpc++ 101pkg-config --libs --static grpc++ 102 103# Build helloworld example using Makefile and pkg-config 104pushd examples/cpp/helloworld 105make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" 106popd 107 108# Build route_guide example using Makefile and pkg-config 109pushd examples/cpp/route_guide 110make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" 111popd 112