Debian Codegraph @

test/distrib/cpp/run_distrib_test_cmake.sh

raw
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 # 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
37 mkdir -p "third_party/cares/cares/cmake/build"
38 pushd "third_party/cares/cares/cmake/build"
39 cmake -DCMAKE_BUILD_TYPE=Release ../..
40 make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
41 popd
42
43 # Install protobuf
44 mkdir -p "third_party/protobuf/cmake/build"
45 pushd "third_party/protobuf/cmake/build"
46 cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ..
47 make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
48 popd
49
50 # Install re2
51 mkdir -p "third_party/re2/cmake/build"
52 pushd "third_party/re2/cmake/build"
53 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../..
54 make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
55 popd
56
57 # Install zlib
58 mkdir -p "third_party/zlib/cmake/build"
59 pushd "third_party/zlib/cmake/build"
60 cmake -DCMAKE_BUILD_TYPE=Release ../..
61 make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
62 popd
63
64 # Just before installing gRPC, wipe out contents of all the submodules to simulate
65 # a standalone build from an archive
66 # shellcheck disable=SC2016
67 git submodule foreach 'cd $toplevel; rm -rf $name'
68
69 # Install gRPC
70 mkdir -p "cmake/build"
71 pushd "cmake/build"
72 cmake \
73 -DCMAKE_BUILD_TYPE=Release \
74 -DgRPC_INSTALL=ON \
75 -DgRPC_BUILD_TESTS=OFF \
76 -DgRPC_CARES_PROVIDER=package \
77 -DgRPC_ABSL_PROVIDER=package \
78 -DgRPC_PROTOBUF_PROVIDER=package \
79 -DgRPC_RE2_PROVIDER=package \
80 -DgRPC_SSL_PROVIDER=package \
81 -DgRPC_ZLIB_PROVIDER=package \
82 ../..
83 make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
84 popd
85
86 # Build helloworld example using cmake
87 mkdir -p "examples/cpp/helloworld/cmake/build"
88 pushd "examples/cpp/helloworld/cmake/build"
89 cmake ../..
90 make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}"
91 popd