run_distrib_test_cmake_pkgconfig.sh 3.1 KB

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