run_distrib_test_cmake.sh 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. set -ex
  16. cd "$(dirname "$0")/../../.."
  17. # Install openssl (to use instead of boringssl)
  18. apt-get update && apt-get install -y libssl-dev
  19. # Use externally provided env to determine build parallelism, otherwise use default.
  20. GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS=${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS:-4}
  21. # Install absl
  22. mkdir -p "third_party/abseil-cpp/cmake/build"
  23. pushd "third_party/abseil-cpp/cmake/build"
  24. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../..
  25. make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
  26. popd
  27. # Install c-ares
  28. # If the distribution provides a new-enough version of c-ares,
  29. # this section can be replaced with:
  30. # apt-get install -y libc-ares-dev
  31. mkdir -p "third_party/cares/cares/cmake/build"
  32. pushd "third_party/cares/cares/cmake/build"
  33. cmake -DCMAKE_BUILD_TYPE=Release ../..
  34. make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
  35. popd
  36. # Install protobuf
  37. mkdir -p "third_party/protobuf/cmake/build"
  38. pushd "third_party/protobuf/cmake/build"
  39. cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ..
  40. make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
  41. popd
  42. # Install re2
  43. mkdir -p "third_party/re2/cmake/build"
  44. pushd "third_party/re2/cmake/build"
  45. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../..
  46. make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
  47. popd
  48. # Install zlib
  49. mkdir -p "third_party/zlib/cmake/build"
  50. pushd "third_party/zlib/cmake/build"
  51. cmake -DCMAKE_BUILD_TYPE=Release ../..
  52. make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
  53. popd
  54. # Just before installing gRPC, wipe out contents of all the submodules to simulate
  55. # a standalone build from an archive
  56. # shellcheck disable=SC2016
  57. git submodule foreach 'cd $toplevel; rm -rf $name'
  58. # Install gRPC
  59. mkdir -p "cmake/build"
  60. pushd "cmake/build"
  61. cmake \
  62. -DCMAKE_BUILD_TYPE=Release \
  63. -DgRPC_INSTALL=ON \
  64. -DgRPC_BUILD_TESTS=OFF \
  65. -DgRPC_CARES_PROVIDER=package \
  66. -DgRPC_ABSL_PROVIDER=package \
  67. -DgRPC_PROTOBUF_PROVIDER=package \
  68. -DgRPC_RE2_PROVIDER=package \
  69. -DgRPC_SSL_PROVIDER=package \
  70. -DgRPC_ZLIB_PROVIDER=package \
  71. ../..
  72. make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
  73. popd
  74. # Build helloworld example using cmake
  75. mkdir -p "examples/cpp/helloworld/cmake/build"
  76. pushd "examples/cpp/helloworld/cmake/build"
  77. cmake ../..
  78. make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}"
  79. popd