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