]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/set_vsprefix_envs.bat
Add VS2019 Support on ToolSetup Batches
[mirror_edk2.git] / BaseTools / set_vsprefix_envs.bat
1 @REM @file
2 @REM This stand-alone program is typically called by the toolsetup.bat file,
3 @REM however it may be executed directly from the BaseTools project folder
4 @REM if the file is not executed within a WORKSPACE\BaseTools folder.
5 @REM
6 @REM Copyright (c) 2016-2019, Intel Corporation. All rights reserved.<BR>
7 @REM
8 @REM SPDX-License-Identifier: BSD-2-Clause-Patent
9 @REM
10
11 @echo off
12 pushd .
13 set SCRIPT_ERROR=0
14 goto main
15
16 :ToolNotInstall
17 set SCRIPT_ERROR=1
18 goto :EOF
19
20 :main
21 if /I "%1"=="VS2019" goto SetVS2019
22 if /I "%1"=="VS2017" goto SetVS2017
23 if /I "%1"=="VS2015" goto SetVS2015
24 if /I "%1"=="VS2013" goto SetVS2013
25 if /I "%1"=="VS2012" goto SetVS2012
26
27 if defined VS71COMNTOOLS (
28 if not defined VS2003_PREFIX (
29 set "VS2003_PREFIX=%VS71COMNTOOLS:~0,-14%"
30 )
31 )
32
33 if defined VS80COMNTOOLS (
34 if not defined VS2005_PREFIX (
35 set "VS2005_PREFIX=%VS80COMNTOOLS:~0,-14%"
36 )
37 )
38
39 if defined VS90COMNTOOLS (
40 if not defined VS2008_PREFIX (
41 set "VS2008_PREFIX=%VS90COMNTOOLS:~0,-14%"
42 )
43 if not defined WINSDK_PREFIX (
44 set "WINSDK_PREFIX=c:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\"
45 )
46 if not defined WINSDKx86_PREFIX (
47 set "WINSDKx86_PREFIX=c:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\bin\"
48 )
49 )
50
51 if defined VS100COMNTOOLS (
52 if not defined VS2010_PREFIX (
53 set "VS2010_PREFIX=%VS100COMNTOOLS:~0,-14%"
54 )
55 if not defined WINSDK7_PREFIX (
56 set "WINSDK7_PREFIX=c:\Program Files\Microsoft SDKs\Windows\v7.0A\Bin\"
57 )
58 if not defined WINSDK7x86_PREFIX (
59 set "WINSDK7x86_PREFIX=c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\"
60 )
61 )
62
63 :SetVS2012
64 if defined VS110COMNTOOLS (
65 if not defined VS2012_PREFIX (
66 set "VS2012_PREFIX=%VS110COMNTOOLS:~0,-14%"
67 )
68 if not defined WINSDK71_PREFIX (
69 set "WINSDK71_PREFIX=c:\Program Files\Microsoft SDKs\Windows\v7.1A\Bin\"
70 )
71 if not defined WINSDK71x86_PREFIX (
72 set "WINSDK71x86_PREFIX=c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\"
73 )
74 ) else (
75 if /I "%1"=="VS2012" goto ToolNotInstall
76 )
77 if /I "%1"=="VS2012" goto SetWinDDK
78
79 :SetVS2013
80 if defined VS120COMNTOOLS (
81 if not defined VS2013_PREFIX (
82 set "VS2013_PREFIX=%VS120COMNTOOLS:~0,-14%"
83 )
84 if not defined WINSDK8_PREFIX (
85 set "WINSDK8_PREFIX=c:\Program Files\Windows Kits\8.0\bin\"
86 )
87 if not defined WINSDK8x86_PREFIX (
88 set "WINSDK8x86_PREFIX=c:\Program Files (x86)\Windows Kits\8.0\bin\"
89 )
90 ) else (
91 if /I "%1"=="VS2013" goto ToolNotInstall
92 )
93 if /I "%1"=="VS2013" goto SetWinDDK
94
95 :SetVS2015
96 if defined VS140COMNTOOLS (
97 if not defined VS2015_PREFIX (
98 set "VS2015_PREFIX=%VS140COMNTOOLS:~0,-14%"
99 )
100 if not defined WINSDK81_PREFIX (
101 set "WINSDK81_PREFIX=c:\Program Files\Windows Kits\8.1\bin\"
102 )
103 if not defined WINSDK81x86_PREFIX (
104 set "WINSDK81x86_PREFIX=c:\Program Files (x86)\Windows Kits\8.1\bin\"
105 )
106 ) else (
107 if /I "%1"=="VS2015" goto ToolNotInstall
108 )
109 if /I "%1"=="VS2015" goto SetWinDDK
110
111 :SetVS2019
112 if not defined VS160COMNTOOLS (
113 if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
114 if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools" (
115 call "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version 16,17 > vswhereInfo
116 for /f "usebackq tokens=1* delims=: " %%i in (vswhereInfo) do (
117 if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
118 )
119 del vswhereInfo
120 ) else (
121 call "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version 16,17 > vswhereInfo
122 for /f "usebackq tokens=1* delims=: " %%i in (vswhereInfo) do (
123 if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
124 )
125 del vswhereInfo
126 )
127 ) else if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
128 if exist "%ProgramFiles%\Microsoft Visual Studio\2019\BuildTools" (
129 call "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version 16,17 > vswhereInfo
130 for /f "usebackq tokens=1* delims=: " %%i in (vswhereInfo) do (
131 if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
132 )
133 del vswhereInfo
134 ) else (
135 call "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -version 16,17 > vswhereInfo
136 for /f "usebackq tokens=1* delims=: " %%i in (vswhereInfo) do (
137 if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
138 )
139 del vswhereInfo
140 )
141 ) else (
142 if /I "%1"=="VS2019" goto ToolNotInstall
143 goto SetWinDDK
144 )
145 )
146
147 if defined VCToolsInstallDir (
148 if not defined VS2019_PREFIX (
149 set "VS2019_PREFIX=%VCToolsInstallDir%"
150 )
151 if not defined WINSDK10_PREFIX (
152 if defined WindowsSdkVerBinPath (
153 set "WINSDK10_PREFIX=%WindowsSdkVerBinPath%"
154 ) else if exist "%ProgramFiles(x86)%\Windows Kits\10\bin" (
155 set "WINSDK10_PREFIX=%ProgramFiles(x86)%\Windows Kits\10\bin\"
156 ) else if exist "%ProgramFiles%\Windows Kits\10\bin" (
157 set "WINSDK10_PREFIX=%ProgramFiles%\Windows Kits\10\bin\"
158 )
159 )
160 )
161
162 :SetVS2017
163 if not defined VS150COMNTOOLS (
164 if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
165 if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools" (
166 call "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version 15,16 > vswhereInfo
167 for /f "usebackq tokens=1* delims=: " %%i in (vswhereInfo) do (
168 if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
169 )
170 del vswhereInfo
171 ) else (
172 call "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version 15,16 > vswhereInfo
173 for /f "usebackq tokens=1* delims=: " %%i in (vswhereInfo) do (
174 if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
175 )
176 del vswhereInfo
177 )
178 ) else if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
179 if exist "%ProgramFiles%\Microsoft Visual Studio\2017\BuildTools" (
180 call "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version 15,16 > vswhereInfo
181 for /f "usebackq tokens=1* delims=: " %%i in (vswhereInfo) do (
182 if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
183 )
184 del vswhereInfo
185 ) else (
186 call "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -version 15,16 > vswhereInfo
187 for /f "usebackq tokens=1* delims=: " %%i in (vswhereInfo) do (
188 if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
189 )
190 del vswhereInfo
191 )
192 ) else (
193 if /I "%1"=="VS2017" goto ToolNotInstall
194 goto SetWinDDK
195 )
196 )
197
198 if defined VCToolsInstallDir (
199 if not defined VS2017_PREFIX (
200 set "VS2017_PREFIX=%VCToolsInstallDir%"
201 )
202 if not defined WINSDK10_PREFIX (
203 if defined WindowsSdkVerBinPath (
204 set "WINSDK10_PREFIX=%WindowsSdkVerBinPath%"
205 ) else if exist "%ProgramFiles(x86)%\Windows Kits\10\bin" (
206 set "WINSDK10_PREFIX=%ProgramFiles(x86)%\Windows Kits\10\bin\"
207 ) else if exist "%ProgramFiles%\Windows Kits\10\bin" (
208 set "WINSDK10_PREFIX=%ProgramFiles%\Windows Kits\10\bin\"
209 )
210 )
211 )
212
213 :SetWinDDK
214 if not defined WINDDK3790_PREFIX (
215 set WINDDK3790_PREFIX=C:\WINDDK\3790.1830\bin\
216 )
217
218 if not defined IASL_PREFIX (
219 set IASL_PREFIX=C:\ASL\
220 )
221
222 popd