setup-buildtools.cmd 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. REM Copyright The OpenTelemetry Authors
  2. REM SPDX-License-Identifier: Apache-2.0
  3. @echo off
  4. setlocal enableextensions
  5. setlocal enabledelayedexpansion
  6. set "PATH=%ProgramFiles%\CMake\bin;%~dp0;%ProgramData%\chocolatey\bin;%PATH%"
  7. if defined VCPKG_ROOT (
  8. set "PATH=%VCPKG_ROOT%;%PATH%"
  9. ) else (
  10. set "PATH=%~dp0vcpkg;%PATH%"
  11. set "VCPKG_ROOT=%~dp0vcpkg"
  12. )
  13. pushd %~dp0
  14. net session >nul 2>&1
  15. if %errorLevel% == 0 (
  16. echo Running with Administrative privilege...
  17. REM Fail if chocolatey is not installed
  18. where /Q choco
  19. if %ERRORLEVEL% == 1 (
  20. echo This script requires chocolatey. Installation instructions: https://chocolatey.org/docs/installation
  21. exit -1
  22. )
  23. REM Install tools needed for building, but only if not installed yet
  24. where /Q vswhere || choco install -y vswhere
  25. where /Q cmake || choco install -y cmake
  26. where /Q git || choco install -y git
  27. ) else (
  28. echo Running without Administrative privilege...
  29. )
  30. if not defined BUILDTOOLS_VERSION (
  31. REM Print current Visual Studio installations detected
  32. where /Q vswhere
  33. if %ERRORLEVEL% == 0 (
  34. echo Visual Studio installations detected:
  35. vswhere -property installationPath
  36. )
  37. )
  38. REM This script allows to pass architecture in ARCH env var
  39. if not defined ARCH (
  40. set ARCH=x64
  41. )
  42. REM Try to autodetect Visual Studio
  43. call "%~dp0vcvars.cmd"
  44. if "%TOOLS_VS_NOTFOUND%" == "1" (
  45. echo WARNING: cannot autodetect Visual Studio installation!
  46. )
  47. where /Q vcpkg.exe
  48. if %ERRORLEVEL% == 1 (
  49. REM Build our own vcpkg from source
  50. REM Prefer building in VCPKG_ROOT
  51. pushd "!VCPKG_ROOT!"
  52. call bootstrap-vcpkg.bat
  53. popd
  54. ) else (
  55. echo Using existing vcpkg installation...
  56. )
  57. REM Install dependencies
  58. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install gtest:%ARCH%-windows
  59. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install --overlay-ports=%~dp0ports benchmark:%ARCH%-windows
  60. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install --overlay-ports=%~dp0ports protobuf:%ARCH%-windows
  61. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install ms-gsl:%ARCH%-windows
  62. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install nlohmann-json:%ARCH%-windows
  63. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install abseil:%ARCH%-windows
  64. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install gRPC:%ARCH%-windows
  65. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install prometheus-cpp:%ARCH%-windows
  66. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install curl:%ARCH%-windows
  67. vcpkg "--vcpkg-root=%VCPKG_ROOT%" install thrift:%ARCH%-windows
  68. popd
  69. exit /b 0