| 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 |
|
| 16 |
set -ex |
| 17 |
|
| 18 |
cd "$(dirname "$0")/../../.." |
| 19 |
|
| 20 |
# Install openssl (to use instead of boringssl) |
| 21 |
apt-get update && apt-get install -y libssl-dev |
| 22 |
|
| 23 |
# Use externally provided env to determine build parallelism, otherwise use default. |
| 24 |
GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS=${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS:-4} |
| 25 |
|
| 26 |
# Install absl |
| 27 |
mkdir -p "third_party/abseil-cpp/cmake/build" |
| 28 |
pushd "third_party/abseil-cpp/cmake/build" |
| 29 |
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../.. |
| 30 |
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install |
| 31 |
popd |
| 32 |
|
| 33 |
# Install c-ares |
| 34 |
mkdir -p "third_party/cares/cares/cmake/build" |
| 35 |
pushd "third_party/cares/cares/cmake/build" |
| 36 |
cmake -DCMAKE_BUILD_TYPE=Release ../.. |
| 37 |
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install |
| 38 |
popd |
| 39 |
|
| 40 |
# Install protobuf |
| 41 |
mkdir -p "third_party/protobuf/cmake/build" |
| 42 |
pushd "third_party/protobuf/cmake/build" |
| 43 |
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release .. |
| 44 |
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install |
| 45 |
popd |
| 46 |
|
| 47 |
# Install re2 |
| 48 |
mkdir -p "third_party/re2/cmake/build" |
| 49 |
pushd "third_party/re2/cmake/build" |
| 50 |
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../.. |
| 51 |
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install |
| 52 |
popd |
| 53 |
|
| 54 |
# Install zlib |
| 55 |
mkdir -p "third_party/zlib/cmake/build" |
| 56 |
pushd "third_party/zlib/cmake/build" |
| 57 |
cmake -DCMAKE_BUILD_TYPE=Release ../.. |
| 58 |
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install |
| 59 |
popd |
| 60 |
|
| 61 |
# Just before installing gRPC, wipe out contents of all the submodules to simulate |
| 62 |
# a standalone build from an archive |
| 63 |
# shellcheck disable=SC2016 |
| 64 |
git submodule foreach 'cd $toplevel; rm -rf $name' |
| 65 |
|
| 66 |
# Install gRPC |
| 67 |
mkdir -p "cmake/build" |
| 68 |
pushd "cmake/build" |
| 69 |
cmake \ |
| 70 |
-DCMAKE_BUILD_TYPE=Release \ |
| 71 |
-DCMAKE_INSTALL_PREFIX=/usr/local/grpc \ |
| 72 |
-DgRPC_INSTALL=ON \ |
| 73 |
-DgRPC_BUILD_TESTS=OFF \ |
| 74 |
-DgRPC_ABSL_PROVIDER=package \ |
| 75 |
-DgRPC_CARES_PROVIDER=package \ |
| 76 |
-DgRPC_PROTOBUF_PROVIDER=package \ |
| 77 |
-DgRPC_RE2_PROVIDER=package \ |
| 78 |
-DgRPC_SSL_PROVIDER=package \ |
| 79 |
-DgRPC_ZLIB_PROVIDER=package \ |
| 80 |
../.. |
| 81 |
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install |
| 82 |
popd |
| 83 |
|
| 84 |
# Build helloworld example using Makefile and pkg-config |
| 85 |
pushd examples/cpp/helloworld |
| 86 |
export PKG_CONFIG_PATH=/usr/local/grpc/lib/pkgconfig |
| 87 |
export PATH=$PATH:/usr/local/grpc/bin |
| 88 |
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" |
| 89 |
popd |
| 90 |
|
| 91 |
# Build route_guide example using Makefile and pkg-config |
| 92 |
pushd examples/cpp/route_guide |
| 93 |
export PKG_CONFIG_PATH=/usr/local/grpc/lib/pkgconfig |
| 94 |
export PATH=$PATH:/usr/local/grpc/bin |
| 95 |
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" |
| 96 |
popd |