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\..\..\.. 18 19mkdir cmake 20cd cmake 21mkdir build 22cd build 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_CMAKE_GENERATOR%" == "Visual Studio 16 2019" ( 33 @rem Always use the newest Windows 10 SDK available. 34 @rem A new-enough Windows 10 SDK that supports C++11's stdalign.h is required 35 @rem for a successful build. 36 @rem By default cmake together with Visual Studio generator 37 @rem pick a version of Win SDK that matches the Windows version, 38 @rem even when a newer version of the SDK available. 39 @rem Setting CMAKE_SYSTEM_VERSION=10.0 changes this behavior 40 @rem to pick the newest Windows SDK available. 41 @rem When using Ninja generator, this problem doesn't happen. 42 @rem See b/275694647 and https://gitlab.kitware.com/cmake/cmake/-/issues/16202#note_140259 43 set "CMAKE_SYSTEM_VERSION_ARG=-DCMAKE_SYSTEM_VERSION=10.0" 44) else ( 45 @rem Setting the env variable to a single space translates to passing no argument 46 @rem when evaluated on the command line. 47 set "CMAKE_SYSTEM_VERSION_ARG= " 48) 49 50If "%GRPC_CMAKE_GENERATOR%" == "Ninja" ( 51 @rem Use ninja 52 53 @rem Select MSVC compiler (cl.exe) explicitly to make sure we don't end up gcc from mingw or cygwin 54 @rem (both are on path in kokoro win workers) 55 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 56 57 ninja -j%GRPC_RUN_TESTS_JOBS% buildtests_%GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX% || goto :error 58 59) else ( 60 @rem Use one of the Visual Studio generators. 61 62 cmake -G "%GRPC_CMAKE_GENERATOR%" -A "%GRPC_CMAKE_ARCHITECTURE%" %CMAKE_SYSTEM_VERSION_ARG% -DCMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE=x64 -DgRPC_BUILD_TESTS=ON -DgRPC_BUILD_MSVC_MP_COUNT=%GRPC_RUN_TESTS_JOBS% %* ../.. || goto :error 63 64 @rem GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX will be set to either "c" or "cxx" 65 cmake --build . --target buildtests_%GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX% --config %MSBUILD_CONFIG% || goto :error 66) 67 68endlocal 69 70goto :EOF 71 72:error 73echo Failed! 74exit /b %errorlevel% 75