run_distrib_test_cmake.bat 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. @rem Copyright 2016 gRPC authors.
  2. @rem
  3. @rem Licensed under the Apache License, Version 2.0 (the "License");
  4. @rem you may not use this file except in compliance with the License.
  5. @rem You may obtain a copy of the License at
  6. @rem
  7. @rem http://www.apache.org/licenses/LICENSE-2.0
  8. @rem
  9. @rem Unless required by applicable law or agreed to in writing, software
  10. @rem distributed under the License is distributed on an "AS IS" BASIS,
  11. @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. @rem See the License for the specific language governing permissions and
  13. @rem limitations under the License.
  14. @rem enter this directory
  15. cd /d %~dp0\..\..\..
  16. @rem TODO(jtattermusch): Kokoro has pre-installed protoc.exe in C:\Program Files\ProtoC and that directory
  17. @rem is on PATH. To avoid picking up the older version protoc.exe, we change the path to something non-existent.
  18. set PATH=%PATH:ProtoC=DontPickupProtoC%
  19. @rem Install into ./testinstall, but use absolute path and foward slashes
  20. set INSTALL_DIR=%cd:\=/%/testinstall
  21. @rem Download OpenSSL-Win32 originally installed from https://slproweb.com/products/Win32OpenSSL.html
  22. powershell -Command "(New-Object Net.WebClient).DownloadFile('https://storage.googleapis.com/grpc-testing.appspot.com/OpenSSL-Win32-1_1_0g.zip', 'OpenSSL-Win32.zip')"
  23. powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('OpenSSL-Win32.zip', '.');"
  24. @rem set absolute path to OpenSSL with forward slashes
  25. set OPENSSL_DIR=%cd:\=/%/OpenSSL-Win32
  26. @rem TODO(jtattermusch): add support for GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS env variable
  27. @rem Install absl
  28. mkdir third_party\abseil-cpp\cmake\build
  29. pushd third_party\abseil-cpp\cmake\build
  30. cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\..
  31. cmake --build . --config Release --target install || goto :error
  32. popd
  33. @rem Install c-ares
  34. mkdir third_party\cares\cares\cmake\build
  35. pushd third_party\cares\cares\cmake\build
  36. cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\..
  37. cmake --build . --config Release --target install || goto :error
  38. popd
  39. @rem Install protobuf
  40. mkdir third_party\protobuf\cmake\build
  41. pushd third_party\protobuf\cmake\build
  42. cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DZLIB_ROOT=%INSTALL_DIR% -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF ..
  43. cmake --build . --config Release --target install || goto :error
  44. popd
  45. @rem Install re2
  46. mkdir third_party\re2\cmake\build
  47. pushd third_party\re2\cmake\build
  48. cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\..
  49. cmake --build . --config Release --target install || goto :error
  50. popd
  51. @rem Install zlib
  52. mkdir third_party\zlib\cmake\build
  53. pushd third_party\zlib\cmake\build
  54. cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\..
  55. cmake --build . --config Release --target install || goto :error
  56. popd
  57. @rem Just before installing gRPC, wipe out contents of all the submodules to simulate
  58. @rem a standalone build from an archive
  59. git submodule deinit --all --force
  60. @rem Install gRPC
  61. mkdir cmake\build
  62. pushd cmake\build
  63. cmake ^
  64. -DCMAKE_BUILD_TYPE=Release ^
  65. -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^
  66. -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% ^
  67. -DZLIB_ROOT=%INSTALL_DIR% ^
  68. -DgRPC_INSTALL=ON ^
  69. -DgRPC_BUILD_TESTS=OFF ^
  70. -DgRPC_BUILD_MSVC_MP_COUNT=-1 ^
  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. ../.. || goto :error
  78. cmake --build . --config Release --target install || goto :error
  79. popd
  80. @rem Build helloworld example using cmake
  81. mkdir examples\cpp\helloworld\cmake\build
  82. pushd examples\cpp\helloworld\cmake\build
  83. cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DZLIB_ROOT=%INSTALL_DIR% ../.. || goto :error
  84. cmake --build . --config Release || goto :error
  85. popd
  86. goto :EOF
  87. :error
  88. echo Failed!
  89. exit /b %errorlevel%