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