VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/BaseTools/toolsetup.bat

Last change on this file was 101291, checked in by vboxsync, 14 months ago

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette