xref: /aosp_15_r20/external/grpc-grpc/tools/run_tests/artifacts/build_artifact_protoc.bat (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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
15mkdir -p %ARTIFACTS_OUT%
16
17@rem enter repo root
18cd /d %~dp0\..\..\..
19
20mkdir cmake
21cd cmake
22mkdir build
23cd build
24
25@rem Use externally provided env to determine build parallelism, otherwise use default.
26if "%GRPC_PROTOC_BUILD_COMPILER_JOBS%"=="" (
27  set GRPC_PROTOC_BUILD_COMPILER_JOBS=2
28)
29
30@rem set cl.exe build environment to build with VS2019 tooling
31@rem this is required for Ninja build to work
32call "%VS160COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %ARCHITECTURE%
33@rem restore command echo
34echo on
35
36@rem Select MSVC compiler (cl.exe) explicitly to make sure we don't end up gcc from mingw or cygwin
37@rem (both are on path in kokoro win workers)
38cmake -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE=Release -DgRPC_BUILD_TESTS=OFF -DgRPC_MSVC_STATIC_RUNTIME=ON ../../.. || goto :error
39
40ninja -j%GRPC_PROTOC_BUILD_COMPILER_JOBS% protoc plugins || goto :error
41cd ..\..
42
43xcopy /Y cmake\build\third_party\protobuf\protoc.exe %ARTIFACTS_OUT%\ || goto :error
44xcopy /Y cmake\build\*_plugin.exe %ARTIFACTS_OUT%\ || goto :error
45
46goto :EOF
47
48:error
49exit /b 1