Debian Codegraph @

tools/internal_ci/helper_scripts/prepare_build_windows.bat

raw
1 @rem Copyright 2017 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
15 @rem allow timing of how long the script takes to run.
16 echo "!TIME!: prepare_build_windows.bat started"
17
18 @rem make sure msys binaries are preferred over cygwin binaries
19 @rem set path to python3.7
20 @rem set path to CMake
21 set PATH=C:\tools\msys64\usr\bin;C:\Python37;C:\Program Files\CMake\bin;%PATH%
22
23 @rem create "python3" link that normally doesn't exist
24 dir C:\Python37\
25 mklink C:\Python37\python3.exe C:\Python37\python.exe
26
27 python --version
28 python3 --version
29
30 @rem If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests
31 if defined KOKORO_GITHUB_PULL_REQUEST_NUMBER if defined RUN_TESTS_FLAGS (
32 set RUN_TESTS_FLAGS=%RUN_TESTS_FLAGS% --filter_pr_tests --base_branch origin/%KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH%
33 )
34
35 @rem Update DNS settings to:
36 @rem 1. allow resolving metadata.google.internal hostname
37 @rem 2. make fetching default GCE credential by oauth2client work
38 netsh interface ip set dns "Local Area Connection 8" static 169.254.169.254 primary
39 netsh interface ip add dnsservers "Local Area Connection 8" 8.8.8.8 index=2
40 netsh interface ip add dnsservers "Local Area Connection 8" 8.8.4.4 index=3
41
42 @rem Uninstall protoc so that it doesn't clash with C++ distribtests.
43 @rem (on grpc-win2016 kokoro workers it can result in GOOGLE_PROTOBUF_MIN_PROTOC_VERSION violation)
44 choco uninstall protoc -y --limit-output
45
46 @rem Install nasm (required for boringssl assembly optimized build as boringssl no long supports yasm)
47 @rem Downloading from GCS should be very reliables when on a GCP VM.
48 mkdir C:\nasm
49 curl -sSL --fail -o C:\nasm\nasm.exe https://storage.googleapis.com/grpc-build-helper/nasm-2.15.05/nasm.exe || goto :error
50 set PATH=C:\nasm;%PATH%
51 nasm
52
53 @rem Install ccache
54 mkdir C:\ccache
55 curl -sSL --fail -o C:\ccache\ccache.exe https://storage.googleapis.com/grpc-build-helper/ccache-4.6-windows-64/ccache.exe || goto :error
56 set PATH=C:\ccache;%PATH%
57 ccache --version
58
59 @rem Only install C# dependencies if we are running C# tests
60 If "%PREPARE_BUILD_INSTALL_DEPS_CSHARP%" == "true" (
61 @rem C# prerequisites: Install dotnet SDK
62 powershell -File src\csharp\install_dotnet_sdk.ps1 || goto :error
63
64 @rem Explicitly add default nuget source.
65 @rem (on Kokoro grpc-win2016 workers, the default nuget source is not configured,
66 @rem which results in errors when "dotnet restore" is run)
67 %LOCALAPPDATA%\Microsoft\dotnet\dotnet nuget add source https://api.nuget.org/v3/index.json -n "nuget.org"
68 )
69
70 @rem Add dotnet on path and disable some unwanted dotnet
71 @rem option regardless of PREPARE_BUILD_INSTALL_DEPS_CSHARP value.
72 @rem Always setting the env vars is fine since its instantaneous,
73 @rem it can't fail and it avoids possible issues with
74 @rem "setlocal" and "EnableDelayedExpansion" which would be required if
75 @rem we wanted to do the same under the IF block.
76 set PATH=%LOCALAPPDATA%\Microsoft\dotnet;%PATH%
77 set NUGET_XMLDOC_MODE=skip
78 set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
79 set DOTNET_CLI_TELEMETRY_OPTOUT=true
80
81 @rem Only install Python interpreters if we are running Python tests
82 If "%PREPARE_BUILD_INSTALL_DEPS_PYTHON%" == "true" (
83 echo "!TIME!: invoking install_python_interpreters.ps1"
84 powershell -File tools\internal_ci\helper_scripts\install_python_interpreters.ps1 || goto :error
85 )
86
87 @rem Needed for uploading test results to bigquery
88 python -m pip install google-api-python-client oauth2client six==1.16.0 || goto :error
89
90 git submodule update --init || goto :error
91
92 echo "!TIME!: prepare_build_windows.bat exiting with success"
93 goto :EOF
94
95 :error
96 echo "!TIME!: prepare_build_windows.bat exiting with error"
97 exit /b 1