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 15setlocal 16 17cd /d %~dp0\..\..\.. 18mkdir cmake 19cd cmake 20mkdir install 21cd .. 22set "INSTALL_PATH=%~dp0\cmake\install" 23 24If "%GRPC_BUILD_ACTIVATE_VS_TOOLS%" == "2019" ( 25 @rem set cl.exe build environment to build with VS2019 tooling 26 @rem this is required for Ninja build to work 27 call "%VS160COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %GRPC_BUILD_VS_TOOLS_ARCHITECTURE% 28 @rem restore command echo 29 echo on 30) 31 32If "%GRPC_BUILD_ACTIVATE_VS_TOOLS%" == "2022" ( 33 @rem set cl.exe build environment to build with VS2022 tooling 34 @rem this is required for Ninja build to work 35 call "%VS170COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %GRPC_BUILD_VS_TOOLS_ARCHITECTURE% 36 @rem restore command echo 37 echo on 38) 39 40@rem Setting the env variable to a single space translates to passing no argument 41@rem when evaluated on the command line. 42set "CMAKE_SYSTEM_VERSION_ARG= " 43 44If "%GRPC_CMAKE_GENERATOR%" == "Visual Studio 16 2019" ( 45 @rem Always use the newest Windows 10 SDK available. 46 @rem A new-enough Windows 10 SDK that supports C++11's stdalign.h is required 47 @rem for a successful build. 48 @rem By default cmake together with Visual Studio generator 49 @rem pick a version of Win SDK that matches the Windows version, 50 @rem even when a newer version of the SDK available. 51 @rem Setting CMAKE_SYSTEM_VERSION=10.0 changes this behavior 52 @rem to pick the newest Windows SDK available. 53 @rem When using Ninja generator, this problem doesn't happen. 54 @rem See b/275694647 and https://gitlab.kitware.com/cmake/cmake/-/issues/16202#note_140259 55 set "CMAKE_SYSTEM_VERSION_ARG=-DCMAKE_SYSTEM_VERSION=10.0" 56) 57 58If "%GRPC_CMAKE_GENERATOR%" == "Visual Studio 17 2022" ( 59 @rem The same as above. 60 set "CMAKE_SYSTEM_VERSION_ARG=-DCMAKE_SYSTEM_VERSION=10.0" 61) 62 63If "%GRPC_CMAKE_GENERATOR%" == "Ninja" ( 64 @rem Use ninja 65 @rem Select MSVC compiler (cl.exe) explicitly to make sure we don't end up gcc from mingw or cygwin 66 @rem (both are on path in kokoro win workers) 67 68 @rem Install abseil-cpp since opentelemetry CMake uses find_package to find it. 69 cd third_party/abseil-cpp 70 mkdir build 71 cd build 72 cmake -G "%GRPC_CMAKE_GENERATOR%" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DABSL_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE="%MSBUILD_CONFIG%" -DCMAKE_INSTALL_PREFIX="%INSTALL_PATH%" %* .. || goto :error 73 ninja -j%GRPC_RUN_TESTS_JOBS% install || goto :error 74 75 @rem Install opentelemetry-cpp since we only support "package" mode for opentelemetry at present. 76 cd ../../.. 77 cd third_party/opentelemetry-cpp 78 mkdir build 79 cd build 80 cmake -G "%GRPC_CMAKE_GENERATOR%" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DWITH_ABSEIL=ON -DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF -DWITH_ETW=OFF -DCMAKE_BUILD_TYPE="%MSBUILD_CONFIG%" -DCMAKE_INSTALL_PREFIX="%INSTALL_PATH%" %* .. || goto :error 81 ninja -j%GRPC_RUN_TESTS_JOBS% install || goto :error 82 83 cd ../../.. 84 85 mkdir cmake 86 cd cmake 87 mkdir build 88 cd build 89 90 cmake -G "%GRPC_CMAKE_GENERATOR%" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DgRPC_BUILD_GRPCPP_OTEL_PLUGIN=ON -DgRPC_ABSL_PROVIDER=package -DgRPC_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE="%MSBUILD_CONFIG%" -DCMAKE_INSTALL_PREFIX="%INSTALL_PATH%" %* ../.. || goto :error 91 92 ninja -j%GRPC_RUN_TESTS_JOBS% buildtests_%GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX% || goto :error 93 94) else ( 95 @rem Use one of the Visual Studio generators. 96 97 @rem Install abseil-cpp since opentelemetry CMake uses find_package to find it. 98 cd third_party/abseil-cpp 99 mkdir build 100 cd build 101 cmake -G "%GRPC_CMAKE_GENERATOR%" -A "%GRPC_CMAKE_ARCHITECTURE%" %CMAKE_SYSTEM_VERSION_ARG% -DCMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE=x64 -DABSL_BUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX="%INSTALL_PATH%" %* .. || goto :error 102 cmake --build . --target install || goto :error 103 104 @rem Install opentelemetry-cpp since we only support "package" mode for opentelemetry at present. 105 cd ../../.. 106 cd third_party/opentelemetry-cpp 107 mkdir build 108 cd build 109 cmake -G "%GRPC_CMAKE_GENERATOR%" -A "%GRPC_CMAKE_ARCHITECTURE%" %CMAKE_SYSTEM_VERSION_ARG% -DCMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE=x64 -DWITH_ABSEIL=ON -DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF -DWITH_ETW=OFF -DCMAKE_INSTALL_PREFIX="%INSTALL_PATH%" %* .. || goto :error 110 cmake --build . --target install -j%GRPC_RUN_TESTS_JOBS% || goto :error 111 112 cd ../../.. 113 mkdir cmake 114 cd cmake 115 mkdir build 116 cd build 117 118 cmake -G "%GRPC_CMAKE_GENERATOR%" -A "%GRPC_CMAKE_ARCHITECTURE%" %CMAKE_SYSTEM_VERSION_ARG% -DCMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE=x64 -DgRPC_BUILD_GRPCPP_OTEL_PLUGIN=ON -DgRPC_ABSL_PROVIDER=package -DgRPC_BUILD_TESTS=ON -DgRPC_BUILD_MSVC_MP_COUNT=%GRPC_RUN_TESTS_JOBS% -DCMAKE_INSTALL_PREFIX="%INSTALL_PATH%" %* ../.. || goto :error 119 120 @rem GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX will be set to either "c" or "cxx" 121 @rem Don't add -j option here because it will disable gRPC_BUILD_MSVC_MP_COUNT option 122 cmake --build . --target buildtests_%GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX% --config %MSBUILD_CONFIG% || goto :error 123) 124 125endlocal 126 127goto :EOF 128 129:error 130echo Failed! 131exit /b %errorlevel% 132