prepare_build_windows.bat 3.6 KB

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