build_cxx.bat 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. @rem Copyright 2022 The 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. setlocal
  15. cd /d %~dp0\..\..\..
  16. mkdir cmake
  17. cd cmake
  18. mkdir build
  19. cd build
  20. If "%GRPC_BUILD_ACTIVATE_VS_TOOLS%" == "2015" (
  21. @rem set cl.exe build environment to build with VS2015 tooling
  22. @rem this is required for Ninja build to work
  23. call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %GRPC_BUILD_VS_TOOLS_ARCHITECTURE%
  24. @rem restore command echo
  25. echo on
  26. )
  27. @rem Workaround a bug where VS150COMNTOOLS is not set due to a bug in VS 2017 installer
  28. @rem see https://developercommunity.visualstudio.com/t/installing-visualstudio-build-tools-doesnt-add-env/17435
  29. set "VS150COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\"
  30. If "%GRPC_BUILD_ACTIVATE_VS_TOOLS%" == "2017" (
  31. @rem set cl.exe build environment to build with VS2017 tooling
  32. @rem this is required for Ninja build to work
  33. call "%VS150COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %GRPC_BUILD_VS_TOOLS_ARCHITECTURE%
  34. @rem restore command echo
  35. echo on
  36. )
  37. If "%GRPC_CMAKE_GENERATOR%" == "Ninja" (
  38. @rem Use ninja
  39. @rem Select MSVC compiler (cl.exe) explicitly to make sure we don't end up gcc from mingw or cygwin
  40. @rem (both are on path in kokoro win workers)
  41. cmake -G "%GRPC_CMAKE_GENERATOR%" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DgRPC_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE="%MSBUILD_CONFIG%" %* ../.. || goto :error
  42. ninja -j%GRPC_RUN_TESTS_JOBS% buildtests_%GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX% || goto :error
  43. ) else (
  44. @rem Use one of the Visual Studio generators.
  45. cmake -G "%GRPC_CMAKE_GENERATOR%" -A "%GRPC_CMAKE_ARCHITECTURE%" -DgRPC_BUILD_TESTS=ON -DgRPC_BUILD_MSVC_MP_COUNT=%GRPC_RUN_TESTS_JOBS% %* ../.. || goto :error
  46. @rem GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX will be set to either "c" or "cxx"
  47. cmake --build . --target buildtests_%GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX% --config %MSBUILD_CONFIG% || goto :error
  48. )
  49. endlocal
  50. goto :EOF
  51. :error
  52. echo Failed!
  53. exit /b %errorlevel%