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.
6 @REM Copyright
(c
) 2006 - 2019, Intel Corporation. All rights reserved.
<BR
>
7 @REM
(C
) Copyright
2016 Hewlett Packard Enterprise Development LP
<BR
>
9 @REM SPDX
-License
-Identifier
: BSD
-2-Clause
-Patent
16 @REM ##############################################################
17 @REM # You should
not have to modify anything below this line
20 if /I
"%1"=="-h" goto Usage
21 if /I
"%1"=="-help" goto Usage
22 if /I
"%1"=="--help" goto Usage
23 if /I
"%1"=="/h" goto Usage
24 if /I
"%1"=="/help" goto Usage
25 if /I
"%1"=="/?" goto Usage
29 if "%1"=="" goto setup_workspace
30 if /I
"%1"=="Reconfig" (
35 if /I
"%1"=="Rebuild" (
40 if /I
"%1"=="ForceRebuild" (
42 set FORCE_REBUILD
=TRUE
45 if /I
"%1"=="VS2019" (
51 if /I
"%1"=="VS2017" (
57 if /I
"%1"=="VS2015" (
63 if /I
"%1"=="VS2013" (
69 if /I
"%1"=="VS2012" (
75 if "%1"=="" goto setup_workspace
77 if not defined BASE_TOOLS_PATH
(
78 if exist %1\Source
set BASE_TOOLS_PATH
=%1
82 if not defined EDK_TOOLS_PATH
(
83 if exist %1\Bin\Win32
set EDK_TOOLS_PATH
=%1
88 echo !!! ERROR
!!! Unknown argument
, %1 !!!
93 echo !!! ERROR
!!! Unknown argument
, %1 !!!
101 @REM Check the required system environment variables
106 REM check the EDK_TOOLS_PATH
108 if not defined EDK_TOOLS_PATH
goto no_EDK_TOOLS_PATH
109 if exist %EDK_TOOLS_PATH% goto set_PATH
112 if not defined WORKSPACE
(
113 if defined BASE_TOOLS_PATH
(
114 set EDK_TOOLS_PATH
=%BASE_TOOLS_PATH%
118 echo !!! ERROR
!!! Neither BASE_TOOLS_PATH nor EDK_TOOLS_PATH are
set.
!!!
123 if exist %WORKSPACE%\BaseTools\Bin
(
124 set EDK_TOOLS_PATH
=%WORKSPACE%\BaseTools
128 echo !!! ERROR
!!! No tools
path available. Please
set EDK_TOOLS_PATH
!!!
135 if defined WORKSPACE_TOOLS_PATH
goto check_PATH
136 if not defined EDK_TOOLS_BIN
(
137 set EDK_TOOLS_BIN
=%EDK_TOOLS_PATH%\Bin\Win32
138 if not exist %EDK_TOOLS_PATH%\Bin\Win32
(
140 echo !!! ERROR
!!! Cannot
find BaseTools Bin Win32
!!!
141 echo Please check the directory
%EDK_TOOLS_PATH%\Bin\Win32
142 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
146 set PATH=%EDK_TOOLS_BIN%;%PATH%
147 set WORKSPACE_TOOLS_PATH
=%EDK_TOOLS_PATH%
151 if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok
152 if not defined EDK_TOOLS_BIN
(
153 set EDK_TOOLS_BIN
=%EDK_TOOLS_PATH%\Bin\Win32
154 if not exist %EDK_TOOLS_PATH%\Bin\Win32
(
156 echo !!! ERROR
!!! Cannot
find BaseTools Bin Win32
!!!
157 echo Please check the directory
%EDK_TOOLS_PATH%\Bin\Win32
158 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
162 set PATH=%EDK_TOOLS_BIN%;%PATH%
163 set WORKSPACE_TOOLS_PATH
=%EDK_TOOLS_PATH%
164 echo Resetting the
PATH variable to include the EDK_TOOLS_PATH
for this session.
168 REM copy *.template to %CONF_PATH%
170 if not defined WORKSPACE
(
171 if defined RECONFIG
(
173 echo !!! WARNING
!!! WORKSPACE environment variable was
not set, cannot Reconfig
!!!
179 IF NOT exist "%EDK_TOOLS_PATH%\set_vsprefix_envs.bat" (
181 @
echo !!! ERROR
!!! The set_vsprefix_envs.bat was
not found
!!!
186 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2019
187 ) else if defined VS2017
(
188 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2017
189 ) else if defined VS2015
(
190 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2015
191 call %EDK_TOOLS_PATH%\get_vsvars.bat VS2015
192 ) else if defined VS2013
(
193 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2013
194 call %EDK_TOOLS_PATH%\get_vsvars.bat VS2013
195 ) else if defined VS2012
(
196 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2012
197 call %EDK_TOOLS_PATH%\get_vsvars.bat VS2012
199 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat
200 call %EDK_TOOLS_PATH%\get_vsvars.bat
202 if %SCRIPT_ERROR% NEQ 0 (
204 @
echo !!! ERROR
!!! %VSTool% is
not installed
!!!
209 if not defined CONF_PATH
(
210 set CONF_PATH
=%WORKSPACE%\Conf
213 if NOT exist %CONF_PATH% (
214 if defined PACKAGES_PATH
(
215 for %%i IN
(%PACKAGES_PATH%) DO (
216 if exist %%~fi\Conf
(
217 set CONF_PATH
=%%i\Conf
225 if NOT exist %CONF_PATH% (
228 if defined RECONFIG
(
230 echo Overwriting the
files in the CONF_PATH directory
231 echo using the default template
files
236 if NOT exist %CONF_PATH%\target.txt
(
237 echo copying ... target.template to
%CONF_PATH%\target.txt
238 if NOT exist %EDK_TOOLS_PATH%\Conf
\target.template
(
239 echo Error
: target.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
241 copy %EDK_TOOLS_PATH%\Conf
\target.template
%CONF_PATH%\target.txt
> nul
243 if defined RECONFIG
echo overwrite ... target.template to
%CONF_PATH%\target.txt
244 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\target.template
%CONF_PATH%\target.txt
> nul
247 if NOT exist %CONF_PATH%\tools_def.txt
(
248 echo copying ... tools_def.template to
%CONF_PATH%\tools_def.txt
249 if NOT exist %EDK_TOOLS_PATH%\Conf
\tools_def.template
(
250 echo Error
: tools_def.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
252 copy %EDK_TOOLS_PATH%\Conf
\tools_def.template
%CONF_PATH%\tools_def.txt
> nul
254 if defined RECONFIG
echo overwrite ... tools_def.template to
%CONF_PATH%\tools_def.txt
255 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\tools_def.template
%CONF_PATH%\tools_def.txt
> nul
258 if NOT exist %CONF_PATH%\build_rule.txt
(
259 echo copying ... build_rule.template to
%CONF_PATH%\build_rule.txt
260 if NOT exist %EDK_TOOLS_PATH%\Conf
\build_rule.template
(
261 echo Error
: build_rule.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
263 copy %EDK_TOOLS_PATH%\Conf
\build_rule.template
%CONF_PATH%\build_rule.txt
> nul
265 if defined RECONFIG
echo over
-write ... build_rule.template to
%CONF_PATH%\build_rule.txt
266 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\build_rule.template
%CONF_PATH%\build_rule.txt
> nul
271 if defined WORKSPACE
(
272 echo WORKSPACE
= %WORKSPACE%
274 if defined PACKAGES_PATH
(
275 echo PACKAGES_PATH
= %PACKAGES_PATH%
277 echo EDK_TOOLS_PATH
= %EDK_TOOLS_PATH%
278 if defined BASE_TOOLS_PATH
(
279 echo BASE_TOOLS_PATH
= %BASE_TOOLS_PATH%
281 if defined EDK_TOOLS_BIN
(
282 echo EDK_TOOLS_BIN
= %EDK_TOOLS_BIN%
284 echo CONF_PATH
= %CONF_PATH%
290 @REM Test
if we are going to have to
do a build
292 if defined FORCE_REBUILD
goto check_build_environment
293 if defined REBUILD
goto check_build_environment
294 if not exist "%EDK_TOOLS_PATH%" goto check_build_environment
295 if not exist "%EDK_TOOLS_BIN%" goto check_build_environment
297 IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools
298 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools
299 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools
300 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools
301 IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools
302 IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools
303 IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools
304 IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools
306 goto check_build_environment
310 echo !!! ERROR
!!! Binary C tools are missing. They are required to be built from BaseTools Source.
313 :check_build_environment
316 if not defined BASE_TOOLS_PATH
(
317 if not exist "Source\C\Makefile" (
318 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files
319 set BASE_TOOLS_PATH
=%EDK_TOOLS_PATH%
321 set BASE_TOOLS_PATH
=%CD%
326 if defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
327 goto check_python_available
329 if defined PYTHON3_ENABLE
(
330 if "%PYTHON3_ENABLE%" EQU
"TRUE" (
331 set PYTHON_COMMAND
=py
-3
332 goto check_python_available
337 if not defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
338 set PYTHON_COMMAND
=py
-3
339 py
-3 %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
340 setlocal enabledelayedexpansion
341 set /p PythonCheck
=<"PythonCheck.txt"
343 if "!PythonCheck!" NEQ "TRUE" (
344 if not defined PYTHON_HOME
if not defined PYTHONHOME
(
348 echo !!! ERROR
!!! Binary python tools are missing.
349 echo PYTHON_COMMAND
, PYTHON3_ENABLE or PYTHON_HOME
350 echo Environment variable is
not set successfully.
351 echo They is required to build or execute the python tools.
358 goto check_freezer_path
364 if defined PYTHON_HOME
(
365 if EXIST "%PYTHON_HOME%" (
366 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
367 goto check_python_available
370 if defined PYTHONHOME
(
371 if EXIST "%PYTHONHOME%" (
372 set PYTHON_HOME
=%PYTHONHOME%
373 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
374 goto check_python_available
378 echo !!! ERROR
!!! PYTHON_HOME is
not defined or The value of this variable does
not exist
381 :check_python_available
382 %PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
383 setlocal enabledelayedexpansion
384 set /p PythonCheck
=<"PythonCheck.txt"
386 if "!PythonCheck!" NEQ "TRUE" (
388 echo ! ERROR
! "%PYTHON_COMMAND%" is
not installed or added to environment variables
392 goto check_freezer_path
400 %PYTHON_COMMAND% -c
"import edk2basetools" >NUL
2>NUL
401 if %ERRORLEVEL% EQU
0 (
402 goto use_pip_basetools
406 goto use_builtin_basetools
409 :use_builtin_basetools
410 @
echo Using EDK2 in
-source Basetools
411 if defined BASETOOLS_PYTHON_SOURCE
goto print_python_info
412 set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"
413 set BASETOOLS_PYTHON_SOURCE
=%BASE_TOOLS_PATH%\Source\Python
414 set PYTHONPATH
=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
415 goto print_python_info
418 @
echo Using Pip Basetools
419 set "PATH=%BASE_TOOLS_PATH%\BinPipWrappers\WindowsLike;%PATH%"
420 set BASETOOLS_PYTHON_SOURCE
=edk2basetools
421 goto print_python_info
425 if defined PYTHON3_ENABLE
if "%PYTHON3_ENABLE%" EQU
"TRUE" (
426 echo PYTHON3_ENABLE
= %PYTHON3_ENABLE%
427 echo PYTHON3
= %PYTHON_COMMAND%
429 echo PYTHON3_ENABLE
= FALSE
430 echo PYTHON_COMMAND
= %PYTHON_COMMAND%
432 echo PYTHONPATH
= %PYTHONPATH%
435 :VisualStudioAvailable
436 if not defined FORCE_REBUILD
(
437 if not defined REBUILD
(
442 if not defined VCINSTALLDIR
(
444 @
echo !!! ERROR
!!!! Cannot
find Visual Studio
, required to build C tools
!!!
448 if not defined FORCE_REBUILD
goto IncrementalBuild
454 del /f
/q
%BASE_TOOLS_PATH%\Bin\Win32\
*.
*
456 @REM Let CleanAndBuild fall through to IncrementalBuild
469 echo !!! ERROR
!!! Cannot build BaseTools applications
- no source directory located
!!!
475 echo Usage
: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]"
477 @
echo base_tools_path BaseTools project
path, BASE_TOOLS_PATH will be
set to this
path.
478 @
echo edk_tools_path EDK_TOOLS_PATH will be
set to this
path.
479 @
echo Rebuild
If sources are available perform an Incremental build
, only
480 @
echo build those updated tools.
481 @
echo ForceRebuild
If sources are available
, rebuild all tools regardless of
482 @
echo whether they have been updated or
not.
483 @
echo Reconfig Reinstall target.txt
, tools_def.txt and build_rule.txt.
484 @
echo VS2012
Set the env
for VS2012 build.
485 @
echo VS2013
Set the env
for VS2013 build.
486 @
echo VS2015
Set the env
for VS2015 build.
487 @
echo VS2017
Set the env
for VS2017 build.
488 @
echo VS2019
Set the env
for VS2019 build.