2
0

vcvars.cmd 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. REM Copyright The OpenTelemetry Authors
  2. REM SPDX-License-Identifier: Apache-2.0
  3. @echo off
  4. REM +-------------------------------------------------------------------+
  5. REM | Autodetect and set up the build environment. |
  6. REM | Build Tools version may be specified as 1st argument. |
  7. REM +-------------------------------------------------------------------+
  8. REM | Description | Argument value |
  9. REM +-----------------------------------------+-------------------------+
  10. REM | Autodetect Visual Studio 2022 | vs2022 |
  11. REM | Visual Studio 2022 Enterprise | vs2022_enterprise |
  12. REM | Visual Studio 2022 Professional | vs2022_professional |
  13. REM | Visual Studio 2022 Community | vs2022_community |
  14. REM | Visual Studio 2022 Build Tools (no IDE) | vs2022_buildtools |
  15. REM | | |
  16. REM | Autodetect Visual Studio 2019 | vs2019 |
  17. REM | Visual Studio 2019 Enterprise | vs2019_enterprise |
  18. REM | Visual Studio 2019 Professional | vs2019_professional |
  19. REM | Visual Studio 2019 Community | vs2019_community |
  20. REM | Visual Studio 2019 Build Tools (no IDE) | vs2019_buildtools |
  21. REM | | |
  22. REM | Autodetect Visual Studio 2017 | vs2017 |
  23. REM | Visual Studio 2017 Enterprise | vs2017_enterprise |
  24. REM | Visual Studio 2017 Professional | vs2017_professional |
  25. REM | Visual Studio 2017 Community | vs2017_community |
  26. REM | Visual Studio 2017 Build Tools (no IDE) | vs2017_buildtools |
  27. REM | | |
  28. REM | Visual Studio 2015 Build Tools (no IDE) | vs2015 |
  29. REM | | |
  30. REM | LLVM Clang (any version) | clang |
  31. REM | LLVM Clang 9 | clang-9 |
  32. REM | LLVM Clang 10 | clang-10 |
  33. REM | LLVM Clang 11 | clang-11 |
  34. REM | LLVM Clang 11 | clang-12 |
  35. REM +-----------------------------------------+-------------------------+
  36. set "VSCMD_START_DIR=%CD%"
  37. if not defined ARCH (
  38. set ARCH=x64
  39. )
  40. if "%1" neq "" (
  41. goto %1
  42. )
  43. if defined BUILDTOOLS_VERSION (
  44. goto %BUILDTOOLS_VERSION%
  45. )
  46. :vs2022
  47. :vs2022_enterprise
  48. set TOOLS_VS2022_ENTERPRISE="%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
  49. if exist %TOOLS_VS2022_ENTERPRISE% (
  50. echo Building with vs2022 Enterprise...
  51. call %TOOLS_VS2022_ENTERPRISE% %ARCH%
  52. goto tools_configured
  53. )
  54. :vs2022_professional
  55. set TOOLS_VS2022_PRO="%ProgramFiles%\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat"
  56. if exist %TOOLS_VS2022_PRO% (
  57. echo Building with vs2022 Professional...
  58. call %TOOLS_VS2022_PRO% %ARCH%
  59. goto tools_configured
  60. )
  61. :vs2022_community
  62. set TOOLS_VS2022_COMMUNITY="%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat"
  63. if exist %TOOLS_VS2022_COMMUNITY% (
  64. echo Building with vs2022 Community...
  65. call %TOOLS_VS2022_COMMUNITY% %ARCH%
  66. goto tools_configured
  67. )
  68. :vs2022_buildtools
  69. set TOOLS_VS2022="%ProgramFiles%\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat"
  70. if exist %TOOLS_VS2022% (
  71. echo Building with vs2022 BuildTools...
  72. call %TOOLS_VS2022% %ARCH%
  73. goto tools_configured
  74. )
  75. :vs2019
  76. :vs2019_enterprise
  77. set TOOLS_VS2019_ENTERPRISE="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
  78. if exist %TOOLS_VS2019_ENTERPRISE% (
  79. echo Building with vs2019 Enterprise...
  80. call %TOOLS_VS2019_ENTERPRISE% %ARCH%
  81. goto tools_configured
  82. )
  83. :vs2019_professional
  84. set TOOLS_VS2019_PRO="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat"
  85. if exist %TOOLS_VS2019_PRO% (
  86. echo Building with vs2019 Professional...
  87. call %TOOLS_VS2019_PRO% %ARCH%
  88. goto tools_configured
  89. )
  90. :vs2019_community
  91. set TOOLS_VS2019_COMMUNITY="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat"
  92. if exist %TOOLS_VS2019_COMMUNITY% (
  93. echo Building with vs2019 Community...
  94. call %TOOLS_VS2019_COMMUNITY% %ARCH%
  95. goto tools_configured
  96. )
  97. :vs2019_buildtools
  98. set TOOLS_VS2019="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat"
  99. if exist %TOOLS_VS2019% (
  100. echo Building with vs2019 BuildTools...
  101. call %TOOLS_VS2019% %ARCH%
  102. goto tools_configured
  103. )
  104. :vs2017
  105. :vs2017_enterprise
  106. set TOOLS_VS2017_ENTERPRISE="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
  107. if exist %TOOLS_VS2017_ENTERPRISE% (
  108. echo Building with vs2017 Enterprise...
  109. call %TOOLS_VS2017_ENTERPRISE% %ARCH%
  110. goto tools_configured
  111. )
  112. :vs2017_professional
  113. set TOOLS_VS2017_PRO="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat"
  114. if exist %TOOLS_VS2017_PRO% (
  115. echo Building with vs2017 Professional...
  116. call %TOOLS_VS2017_PRO% %ARCH%
  117. goto tools_configured
  118. )
  119. :vs2017_community
  120. set TOOLS_VS2017_COMMUNITY="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\VC\Auxiliary\Build\vcvarsall.bat"
  121. if exist %TOOLS_VS2017_COMMUNITY% (
  122. echo Building with vs2017 Community...
  123. call %TOOLS_VS2017_COMMUNITY% %ARCH%
  124. goto tools_configured
  125. )
  126. :vs2017_buildtools
  127. set TOOLS_VS2017="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat"
  128. if exist %TOOLS_VS2017% (
  129. echo Building with vs2017 BuildTools...
  130. call %TOOLS_VS2017% %ARCH%
  131. goto tools_configured
  132. )
  133. :vs2015
  134. set TOOLS_VS2015="%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
  135. if exist %TOOLS_VS2015% (
  136. echo Building with vs2015 BuildTools...
  137. call %TOOLS_VS2015% %ARCH% %WINSDK_VERSION%
  138. set "VCPKG_VISUAL_STUDIO_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0"
  139. set VCPKG_PLATFORM_TOOLSET=v140
  140. goto tools_configured
  141. )
  142. echo WARNING: cannot auto-detect Visual Studio version !!!
  143. REM Caller may decide what to do if Visual Studio environment
  144. REM is not set up by checking TOOLS_VS_NOTFOUND
  145. set TOOLS_VS_NOTFOUND=1
  146. exit /b 0
  147. REM +-------------------------------------------------------------------+
  148. REM | There is no auto-detection of LLVM Clang version. |
  149. REM | LLVM Clang of any version is installed in the same directory |
  150. REM | at %ProgramFiles%\LLVM\bin . Developers choose their own custom |
  151. REM | layout for installing multiple clang toolchains side-by-side. |
  152. REM | |
  153. REM | Example layout (merely a guideline, layout could differ): |
  154. REM | |
  155. REM | %ProgramFiles%\LLVM-9\bin |
  156. REM | %ProgramFiles%\LLVM-10\bin |
  157. REM | %ProgramFiles%\LLVM-11\bin |
  158. REM | %ProgramFiles%\LLVM-12\bin |
  159. REM +-------------------------------------------------------------------+
  160. REM
  161. REM ## Example 1: use clang-10 located in LLVM-10 directory:
  162. REM set BUILDTOOLS_VERSION=clang-10
  163. REM set "PATH=%ProgramFiles%\LLVM-10\bin;%PATH%"
  164. REM tools\build.cmd
  165. REM
  166. REM ## Example 2: use whatever clang located in LLVM directory:
  167. REM set BUILDTOOLS_VERSION=clang
  168. REM set "PATH=%ProgramFiles%\LLVM\bin;%PATH%"
  169. REM tools\build.cmd
  170. REM
  171. REM BUILDTOOLS_VERSION determines the output directory location.
  172. REM Store build artifacts produced by different toolchains -
  173. REM side-by-side, each in its own separate output directory.
  174. REM
  175. :clang
  176. :clang-9
  177. :clang-10
  178. :clang-11
  179. :clang-12
  180. :tools_configured