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