]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - BaseTools/toolsetup.bat
BaseTools: Remove deprecated Visual Studio Option
[mirror_edk2.git] / BaseTools / toolsetup.bat
... / ...
CommitLineData
1@REM @file\r
2@REM This stand-alone program is typically called by the edksetup.bat file,\r
3@REM however it may be executed directly from the BaseTools project folder\r
4@REM if the file is not executed within a WORKSPACE\BaseTools folder.\r
5@REM\r
6@REM Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
7@REM (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
8@REM\r
9@REM SPDX-License-Identifier: BSD-2-Clause-Patent\r
10@REM\r
11\r
12@echo off\r
13pushd .\r
14set SCRIPT_ERROR=0\r
15\r
16@REM ##############################################################\r
17@REM # You should not have to modify anything below this line\r
18@REM #\r
19\r
20if /I "%1"=="-h" goto Usage\r
21if /I "%1"=="-help" goto Usage\r
22if /I "%1"=="--help" goto Usage\r
23if /I "%1"=="/h" goto Usage\r
24if /I "%1"=="/help" goto Usage\r
25if /I "%1"=="/?" goto Usage\r
26\r
27\r
28:loop\r
29 if "%1"=="" goto setup_workspace\r
30 if /I "%1"=="Reconfig" (\r
31 shift\r
32 set RECONFIG=TRUE\r
33 goto loop\r
34 )\r
35 if /I "%1"=="Rebuild" (\r
36 shift\r
37 set REBUILD=TRUE\r
38 goto loop\r
39 )\r
40 if /I "%1"=="ForceRebuild" (\r
41 shift\r
42 set FORCE_REBUILD=TRUE\r
43 goto loop\r
44 )\r
45 if /I "%1"=="VS2019" (\r
46 shift\r
47 set VS2019=TRUE\r
48 set VSTool=VS2019\r
49 goto loop\r
50 )\r
51 if /I "%1"=="VS2017" (\r
52 shift\r
53 set VS2017=TRUE\r
54 set VSTool=VS2017\r
55 goto loop\r
56 )\r
57 if /I "%1"=="VS2015" (\r
58 shift\r
59 set VS2015=TRUE\r
60 set VSTool=VS2015\r
61 goto loop\r
62 )\r
63 if /I "%1"=="VS2013" (\r
64 shift\r
65 set VS2013=TRUE\r
66 set VSTool=VS2013\r
67 goto loop\r
68 )\r
69 if /I "%1"=="VS2012" (\r
70 shift\r
71 set VS2012=TRUE\r
72 set VSTool=VS2012\r
73 goto loop\r
74 )\r
75 if "%1"=="" goto setup_workspace\r
76 if exist %1 (\r
77 if not defined BASE_TOOLS_PATH (\r
78 if exist %1\Source set BASE_TOOLS_PATH=%1\r
79 shift\r
80 goto loop\r
81 )\r
82 if not defined EDK_TOOLS_PATH (\r
83 if exist %1\Bin\Win32 set EDK_TOOLS_PATH=%1\r
84 shift\r
85 goto loop\r
86 )\r
87 echo.\r
88 echo !!! ERROR !!! Unknown argument, %1 !!!\r
89 echo.\r
90 goto end\r
91 ) else (\r
92 echo.\r
93 echo !!! ERROR !!! Unknown argument, %1 !!!\r
94 echo.\r
95 goto end\r
96 )\r
97 goto loop\r
98\r
99\r
100@REM\r
101@REM Check the required system environment variables\r
102@REM\r
103\r
104:setup_workspace\r
105 REM\r
106 REM check the EDK_TOOLS_PATH\r
107 REM\r
108 if not defined EDK_TOOLS_PATH goto no_EDK_TOOLS_PATH\r
109 if exist %EDK_TOOLS_PATH% goto set_PATH\r
110\r
111:no_EDK_TOOLS_PATH\r
112 if not defined WORKSPACE (\r
113 if defined BASE_TOOLS_PATH (\r
114 set EDK_TOOLS_PATH=%BASE_TOOLS_PATH%\r
115 goto set_PATH\r
116 ) else (\r
117 echo.\r
118 echo !!! ERROR !!! Neither BASE_TOOLS_PATH nor EDK_TOOLS_PATH are set. !!!\r
119 echo.\r
120 goto end\r
121 )\r
122 ) else (\r
123 if exist %WORKSPACE%\BaseTools\Bin (\r
124 set EDK_TOOLS_PATH=%WORKSPACE%\BaseTools\r
125 goto set_PATH\r
126 ) else (\r
127 echo.\r
128 echo !!! ERROR !!! No tools path available. Please set EDK_TOOLS_PATH !!!\r
129 echo.\r
130 goto end\r
131 )\r
132 )\r
133\r
134:set_PATH\r
135 if defined WORKSPACE_TOOLS_PATH goto check_PATH\r
136 if not defined EDK_TOOLS_BIN (\r
137 set EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32\r
138 if not exist %EDK_TOOLS_PATH%\Bin\Win32 (\r
139 echo.\r
140 echo !!! ERROR !!! Cannot find BaseTools Bin Win32!!!\r
141 echo Please check the directory %EDK_TOOLS_PATH%\Bin\Win32\r
142 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.\r
143 echo.\r
144 )\r
145 )\r
146 set PATH=%EDK_TOOLS_BIN%;%PATH%\r
147 set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
148 goto PATH_ok\r
149\r
150:check_PATH\r
151 if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok\r
152 if not defined EDK_TOOLS_BIN (\r
153 set EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32\r
154 if not exist %EDK_TOOLS_PATH%\Bin\Win32 (\r
155 echo.\r
156 echo !!! ERROR !!! Cannot find BaseTools Bin Win32!!!\r
157 echo Please check the directory %EDK_TOOLS_PATH%\Bin\Win32\r
158 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.\r
159 echo.\r
160 )\r
161 )\r
162 set PATH=%EDK_TOOLS_BIN%;%PATH%\r
163 set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
164 echo Resetting the PATH variable to include the EDK_TOOLS_PATH for this session.\r
165\r
166:PATH_ok\r
167REM\r
168REM copy *.template to %CONF_PATH%\r
169REM\r
170if not defined WORKSPACE (\r
171 if defined RECONFIG (\r
172 echo.\r
173 echo !!! WARNING !!! WORKSPACE environment variable was not set, cannot Reconfig !!!\r
174 echo.\r
175 )\r
176 goto skip_reconfig\r
177)\r
178\r
179IF NOT exist "%EDK_TOOLS_PATH%\set_vsprefix_envs.bat" (\r
180 @echo.\r
181 @echo !!! ERROR !!! The set_vsprefix_envs.bat was not found !!!\r
182 @echo.\r
183 goto end\r
184)\r
185if defined VS2019 (\r
186 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2019\r
187) else if defined VS2017 (\r
188 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2017\r
189) else if defined VS2015 (\r
190 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2015\r
191 call %EDK_TOOLS_PATH%\get_vsvars.bat VS2015\r
192) else if defined VS2013 (\r
193 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2013\r
194 call %EDK_TOOLS_PATH%\get_vsvars.bat VS2013\r
195) else if defined VS2012 (\r
196 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2012\r
197 call %EDK_TOOLS_PATH%\get_vsvars.bat VS2012\r
198) else (\r
199 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat\r
200 call %EDK_TOOLS_PATH%\get_vsvars.bat\r
201)\r
202if %SCRIPT_ERROR% NEQ 0 (\r
203 @echo.\r
204 @echo !!! ERROR !!! %VSTool% is not installed !!!\r
205 @echo.\r
206 goto end\r
207)\r
208\r
209if not defined CONF_PATH (\r
210 set CONF_PATH=%WORKSPACE%\Conf\r
211)\r
212\r
213if NOT exist %CONF_PATH% (\r
214 if defined PACKAGES_PATH (\r
215 for %%i IN (%PACKAGES_PATH%) DO (\r
216 if exist %%~fi\Conf (\r
217 set CONF_PATH=%%i\Conf\r
218 goto CopyConf\r
219 )\r
220 )\r
221 )\r
222)\r
223\r
224:CopyConf\r
225if NOT exist %CONF_PATH% (\r
226 mkdir %CONF_PATH%\r
227) else (\r
228 if defined RECONFIG (\r
229 echo.\r
230 echo Over-writing the files in the CONF_PATH directory\r
231 echo using the default template files\r
232 echo.\r
233 )\r
234)\r
235\r
236if NOT exist %CONF_PATH%\target.txt (\r
237 echo copying ... target.template to %CONF_PATH%\target.txt\r
238 if NOT exist %EDK_TOOLS_PATH%\Conf\target.template (\r
239 echo Error: target.template is missing at folder %EDK_TOOLS_PATH%\Conf\\r
240 )\r
241 copy %EDK_TOOLS_PATH%\Conf\target.template %CONF_PATH%\target.txt > nul\r
242) else (\r
243 if defined RECONFIG echo over-write ... target.template to %CONF_PATH%\target.txt\r
244 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\target.template %CONF_PATH%\target.txt > nul\r
245)\r
246\r
247if NOT exist %CONF_PATH%\tools_def.txt (\r
248 echo copying ... tools_def.template to %CONF_PATH%\tools_def.txt\r
249 if NOT exist %EDK_TOOLS_PATH%\Conf\tools_def.template (\r
250 echo Error: tools_def.template is missing at folder %EDK_TOOLS_PATH%\Conf\\r
251 )\r
252 copy %EDK_TOOLS_PATH%\Conf\tools_def.template %CONF_PATH%\tools_def.txt > nul\r
253) else (\r
254 if defined RECONFIG echo over-write ... tools_def.template to %CONF_PATH%\tools_def.txt\r
255 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\tools_def.template %CONF_PATH%\tools_def.txt > nul\r
256)\r
257\r
258if NOT exist %CONF_PATH%\build_rule.txt (\r
259 echo copying ... build_rule.template to %CONF_PATH%\build_rule.txt\r
260 if NOT exist %EDK_TOOLS_PATH%\Conf\build_rule.template (\r
261 echo Error: build_rule.template is missing at folder %EDK_TOOLS_PATH%\Conf\\r
262 )\r
263 copy %EDK_TOOLS_PATH%\Conf\build_rule.template %CONF_PATH%\build_rule.txt > nul\r
264) else (\r
265 if defined RECONFIG echo over-write ... build_rule.template to %CONF_PATH%\build_rule.txt\r
266 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\build_rule.template %CONF_PATH%\build_rule.txt > nul\r
267)\r
268\r
269echo PATH = %PATH%\r
270echo.\r
271if defined WORKSPACE (\r
272 echo WORKSPACE = %WORKSPACE%\r
273)\r
274if defined PACKAGES_PATH (\r
275 echo PACKAGES_PATH = %PACKAGES_PATH%\r
276)\r
277echo EDK_TOOLS_PATH = %EDK_TOOLS_PATH%\r
278if defined BASE_TOOLS_PATH (\r
279 echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%\r
280)\r
281if defined EDK_TOOLS_BIN (\r
282 echo EDK_TOOLS_BIN = %EDK_TOOLS_BIN%\r
283)\r
284echo CONF_PATH = %CONF_PATH%\r
285echo.\r
286\r
287:skip_reconfig\r
288\r
289@REM\r
290@REM Test if we are going to have to do a build\r
291@REM\r
292if defined FORCE_REBUILD goto check_build_environment\r
293if defined REBUILD goto check_build_environment\r
294if not exist "%EDK_TOOLS_PATH%" goto check_build_environment\r
295if not exist "%EDK_TOOLS_BIN%" goto check_build_environment\r
296\r
297IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools\r
298IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools\r
299IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools\r
300IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools\r
301IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools\r
302IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools\r
303IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools\r
304IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools\r
305IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools\r
306\r
307goto check_build_environment\r
308\r
309:check_c_tools\r
310 echo.\r
311 echo !!! ERROR !!! Binary C tools are missing. They are required to be built from BaseTools Source.\r
312 echo.\r
313\r
314:check_build_environment\r
315 set PYTHONHASHSEED=1\r
316\r
317 if not defined BASE_TOOLS_PATH (\r
318 if not exist "Source\C\Makefile" (\r
319 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files\r
320 set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
321 ) else (\r
322 set BASE_TOOLS_PATH=%CD%\r
323 )\r
324 )\r
325\r
326:defined_python\r
327if defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
328 goto check_python_available\r
329)\r
330if defined PYTHON3_ENABLE (\r
331 if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
332 set PYTHON_COMMAND=py -3\r
333 goto check_python_available\r
334 ) else (\r
335 goto check_python2\r
336 )\r
337)\r
338if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
339 set PYTHON_COMMAND=py -3\r
340 py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
341 setlocal enabledelayedexpansion\r
342 set /p PythonCheck=<"PythonCheck.txt"\r
343 del PythonCheck.txt\r
344 if "!PythonCheck!" NEQ "TRUE" (\r
345 if not defined PYTHON_HOME if not defined PYTHONHOME (\r
346 endlocal\r
347 set PYTHON_COMMAND=\r
348 echo.\r
349 echo !!! ERROR !!! Binary python tools are missing.\r
350 echo PYTHON_COMMAND, PYTHON3_ENABLE or PYTHON_HOME\r
351 echo Environment variable is not set successfully.\r
352 echo They is required to build or execute the python tools.\r
353 echo.\r
354 goto end\r
355 ) else (\r
356 goto check_python2\r
357 )\r
358 ) else (\r
359 goto check_freezer_path\r
360 )\r
361)\r
362\r
363:check_python2\r
364endlocal\r
365if defined PYTHON_HOME (\r
366 if EXIST "%PYTHON_HOME%" (\r
367 set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
368 goto check_python_available\r
369 )\r
370)\r
371if defined PYTHONHOME (\r
372 if EXIST "%PYTHONHOME%" (\r
373 set PYTHON_HOME=%PYTHONHOME%\r
374 set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
375 goto check_python_available\r
376 )\r
377)\r
378echo.\r
379echo !!! ERROR !!! PYTHON_HOME is not defined or The value of this variable does not exist\r
380echo.\r
381goto end\r
382:check_python_available\r
383%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
384 setlocal enabledelayedexpansion\r
385 set /p PythonCheck=<"PythonCheck.txt"\r
386 del PythonCheck.txt\r
387 if "!PythonCheck!" NEQ "TRUE" (\r
388 echo.\r
389 echo ! ERROR ! "%PYTHON_COMMAND%" is not installed or added to environment variables\r
390 echo.\r
391 goto end\r
392 ) else (\r
393 goto check_freezer_path\r
394 )\r
395\r
396:check_freezer_path\r
397 endlocal\r
398 if defined BASETOOLS_PYTHON_SOURCE goto print_python_info\r
399 set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"\r
400 set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r
401 set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r
402\r
403:print_python_info\r
404 echo PATH = %PATH%\r
405 if defined PYTHON3_ENABLE if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
406 echo PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
407 echo PYTHON3 = %PYTHON_COMMAND%\r
408 ) else (\r
409 echo PYTHON3_ENABLE = FALSE\r
410 echo PYTHON_COMMAND = %PYTHON_COMMAND%\r
411 )\r
412 echo PYTHONPATH = %PYTHONPATH%\r
413 echo.\r
414\r
415:VisualStudioAvailable\r
416 if not defined FORCE_REBUILD (\r
417 if not defined REBUILD (\r
418 goto end\r
419 )\r
420 )\r
421\r
422 if not defined VCINSTALLDIR (\r
423 @echo.\r
424 @echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!\r
425 @echo.\r
426 goto end\r
427 )\r
428 if not defined FORCE_REBUILD goto IncrementalBuild\r
429\r
430:CleanAndBuild\r
431 pushd .\r
432 cd %BASE_TOOLS_PATH%\r
433 call nmake cleanall\r
434 del /f /q %BASE_TOOLS_PATH%\Bin\Win32\*.*\r
435 popd\r
436 @REM Let CleanAndBuild fall through to IncrementalBuild\r
437\r
438\r
439:IncrementalBuild\r
440 pushd .\r
441 cd %BASE_TOOLS_PATH%\r
442 call nmake c\r
443 popd\r
444 goto end\r
445\r
446\r
447:no_source_files\r
448 echo.\r
449 echo !!! ERROR !!! Cannot build BaseTools applications - no source directory located !!!\r
450 echo.\r
451 goto end\r
452\r
453:Usage\r
454 @echo.\r
455 echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]"\r
456 @echo.\r
457 @echo base_tools_path BaseTools project path, BASE_TOOLS_PATH will be set to this path.\r
458 @echo edk_tools_path EDK_TOOLS_PATH will be set to this path.\r
459 @echo Rebuild If sources are available perform an Incremental build, only\r
460 @echo build those updated tools.\r
461 @echo ForceRebuild If sources are available, rebuild all tools regardless of\r
462 @echo whether they have been updated or not.\r
463 @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.\r
464 @echo VS2012 Set the env for VS2012 build.\r
465 @echo VS2013 Set the env for VS2013 build.\r
466 @echo VS2015 Set the env for VS2015 build.\r
467 @echo VS2017 Set the env for VS2017 build.\r
468 @echo VS2019 Set the env for VS2019 build.\r
469 @echo.\r
470\r
471:end\r
472set REBUILD=\r
473set FORCE_REBUILD=\r
474set RECONFIG=\r
475set VS2019=\r
476set VS2017=\r
477set VS2015=\r
478set VS2013=\r
479set VS2012=\r
480set VSTool=\r
481popd\r
482\r