]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - BaseTools/toolsetup.bat
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 Overwriting 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 overwrite ... 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 overwrite ... 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%\TianoCompress.exe" goto check_c_tools\r
303IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools\r
304IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools\r
305\r
306goto check_build_environment\r
307\r
308:check_c_tools\r
309 echo.\r
310 echo !!! ERROR !!! Binary C tools are missing. They are required to be built from BaseTools Source.\r
311 echo.\r
312\r
313:check_build_environment\r
314 set PYTHONHASHSEED=1\r
315\r
316 if not defined BASE_TOOLS_PATH (\r
317 if not exist "Source\C\Makefile" (\r
318 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files\r
319 set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
320 ) else (\r
321 set BASE_TOOLS_PATH=%CD%\r
322 )\r
323 )\r
324\r
325:defined_python\r
326if defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
327 goto check_python_available\r
328)\r
329if defined PYTHON3_ENABLE (\r
330 if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
331 set PYTHON_COMMAND=py -3\r
332 goto check_python_available\r
333 ) else (\r
334 goto check_python2\r
335 )\r
336)\r
337if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
338 set PYTHON_COMMAND=py -3\r
339 py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
340 setlocal enabledelayedexpansion\r
341 set /p PythonCheck=<"PythonCheck.txt"\r
342 del PythonCheck.txt\r
343 if "!PythonCheck!" NEQ "TRUE" (\r
344 if not defined PYTHON_HOME if not defined PYTHONHOME (\r
345 endlocal\r
346 set PYTHON_COMMAND=\r
347 echo.\r
348 echo !!! ERROR !!! Binary python tools are missing.\r
349 echo PYTHON_COMMAND, PYTHON3_ENABLE or PYTHON_HOME\r
350 echo Environment variable is not set successfully.\r
351 echo They is required to build or execute the python tools.\r
352 echo.\r
353 goto end\r
354 ) else (\r
355 goto check_python2\r
356 )\r
357 ) else (\r
358 goto check_freezer_path\r
359 )\r
360)\r
361\r
362:check_python2\r
363endlocal\r
364if defined PYTHON_HOME (\r
365 if EXIST "%PYTHON_HOME%" (\r
366 set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
367 goto check_python_available\r
368 )\r
369)\r
370if defined PYTHONHOME (\r
371 if EXIST "%PYTHONHOME%" (\r
372 set PYTHON_HOME=%PYTHONHOME%\r
373 set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
374 goto check_python_available\r
375 )\r
376)\r
377echo.\r
378echo !!! ERROR !!! PYTHON_HOME is not defined or The value of this variable does not exist\r
379echo.\r
380goto end\r
381:check_python_available\r
382%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
383 setlocal enabledelayedexpansion\r
384 set /p PythonCheck=<"PythonCheck.txt"\r
385 del PythonCheck.txt\r
386 if "!PythonCheck!" NEQ "TRUE" (\r
387 echo.\r
388 echo ! ERROR ! "%PYTHON_COMMAND%" is not installed or added to environment variables\r
389 echo.\r
390 goto end\r
391 ) else (\r
392 goto check_freezer_path\r
393 )\r
394\r
395\r
396\r
397:check_freezer_path\r
398 endlocal\r
399\r
400 %PYTHON_COMMAND% -c "import edk2basetools" >NUL 2>NUL\r
401 if %ERRORLEVEL% EQU 0 (\r
402 goto use_pip_basetools\r
403 ) else (\r
404 REM reset ERRORLEVEL\r
405 type nul>nul\r
406 goto use_builtin_basetools\r
407 )\r
408\r
409:use_builtin_basetools\r
410 @echo Using EDK2 in-source Basetools\r
411 if defined BASETOOLS_PYTHON_SOURCE goto print_python_info\r
412 set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"\r
413 set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r
414 set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r
415 goto print_python_info\r
416\r
417:use_pip_basetools\r
418 @echo Using Pip Basetools\r
419 set "PATH=%BASE_TOOLS_PATH%\BinPipWrappers\WindowsLike;%PATH%"\r
420 set BASETOOLS_PYTHON_SOURCE=edk2basetools\r
421 goto print_python_info\r
422\r
423:print_python_info\r
424 echo PATH = %PATH%\r
425 if defined PYTHON3_ENABLE if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
426 echo PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
427 echo PYTHON3 = %PYTHON_COMMAND%\r
428 ) else (\r
429 echo PYTHON3_ENABLE = FALSE\r
430 echo PYTHON_COMMAND = %PYTHON_COMMAND%\r
431 )\r
432 echo PYTHONPATH = %PYTHONPATH%\r
433 echo.\r
434\r
435:VisualStudioAvailable\r
436 if not defined FORCE_REBUILD (\r
437 if not defined REBUILD (\r
438 goto end\r
439 )\r
440 )\r
441\r
442 if not defined VCINSTALLDIR (\r
443 @echo.\r
444 @echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!\r
445 @echo.\r
446 goto end\r
447 )\r
448 if not defined FORCE_REBUILD goto IncrementalBuild\r
449\r
450:CleanAndBuild\r
451 pushd .\r
452 cd %BASE_TOOLS_PATH%\r
453 call nmake cleanall\r
454 del /f /q %BASE_TOOLS_PATH%\Bin\Win32\*.*\r
455 popd\r
456 @REM Let CleanAndBuild fall through to IncrementalBuild\r
457\r
458\r
459:IncrementalBuild\r
460 pushd .\r
461 cd %BASE_TOOLS_PATH%\r
462 call nmake c\r
463 popd\r
464 goto end\r
465\r
466\r
467:no_source_files\r
468 echo.\r
469 echo !!! ERROR !!! Cannot build BaseTools applications - no source directory located !!!\r
470 echo.\r
471 goto end\r
472\r
473:Usage\r
474 @echo.\r
475 echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]"\r
476 @echo.\r
477 @echo base_tools_path BaseTools project path, BASE_TOOLS_PATH will be set to this path.\r
478 @echo edk_tools_path EDK_TOOLS_PATH will be set to this path.\r
479 @echo Rebuild If sources are available perform an Incremental build, only\r
480 @echo build those updated tools.\r
481 @echo ForceRebuild If sources are available, rebuild all tools regardless of\r
482 @echo whether they have been updated or not.\r
483 @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.\r
484 @echo VS2012 Set the env for VS2012 build.\r
485 @echo VS2013 Set the env for VS2013 build.\r
486 @echo VS2015 Set the env for VS2015 build.\r
487 @echo VS2017 Set the env for VS2017 build.\r
488 @echo VS2019 Set the env for VS2019 build.\r
489 @echo.\r
490\r
491:end\r
492set REBUILD=\r
493set FORCE_REBUILD=\r
494set RECONFIG=\r
495set VS2019=\r
496set VS2017=\r
497set VS2015=\r
498set VS2013=\r
499set VS2012=\r
500set VSTool=\r
501popd\r
502\r