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 Over
-writing 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 over
-write ... 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 over
-write ... 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%\Split.exe" goto check_c_tools
303 IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools
304 IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools
305 IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools
307 goto check_build_environment
311 echo !!! ERROR
!!! Binary C tools are missing. They are required to be built from BaseTools Source.
314 :check_build_environment
317 if not defined BASE_TOOLS_PATH
(
318 if not exist "Source\C\Makefile" (
319 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files
320 set BASE_TOOLS_PATH
=%EDK_TOOLS_PATH%
322 set BASE_TOOLS_PATH
=%CD%
327 if defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
328 goto check_python_available
330 if defined PYTHON3_ENABLE
(
331 if "%PYTHON3_ENABLE%" EQU
"TRUE" (
332 set PYTHON_COMMAND
=py
-3
333 goto check_python_available
338 if not defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
339 set PYTHON_COMMAND
=py
-3
340 py
-3 %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
341 setlocal enabledelayedexpansion
342 set /p PythonCheck
=<"PythonCheck.txt"
344 if "!PythonCheck!" NEQ "TRUE" (
345 if not defined PYTHON_HOME
if not defined PYTHONHOME
(
349 echo !!! ERROR
!!! Binary python tools are missing.
350 echo PYTHON_COMMAND
, PYTHON3_ENABLE or PYTHON_HOME
351 echo Environment variable is
not set successfully.
352 echo They is required to build or execute the python tools.
359 goto check_freezer_path
365 if defined PYTHON_HOME
(
366 if EXIST "%PYTHON_HOME%" (
367 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
368 goto check_python_available
371 if defined PYTHONHOME
(
372 if EXIST "%PYTHONHOME%" (
373 set PYTHON_HOME
=%PYTHONHOME%
374 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
375 goto check_python_available
379 echo !!! ERROR
!!! PYTHON_HOME is
not defined or The value of this variable does
not exist
382 :check_python_available
383 %PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
384 setlocal enabledelayedexpansion
385 set /p PythonCheck
=<"PythonCheck.txt"
387 if "!PythonCheck!" NEQ "TRUE" (
389 echo ! ERROR
! "%PYTHON_COMMAND%" is
not installed or added to environment variables
393 goto check_freezer_path
398 if defined BASETOOLS_PYTHON_SOURCE
goto print_python_info
399 set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"
400 set BASETOOLS_PYTHON_SOURCE
=%BASE_TOOLS_PATH%\Source\Python
401 set PYTHONPATH
=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
405 if defined PYTHON3_ENABLE
if "%PYTHON3_ENABLE%" EQU
"TRUE" (
406 echo PYTHON3_ENABLE
= %PYTHON3_ENABLE%
407 echo PYTHON3
= %PYTHON_COMMAND%
409 echo PYTHON3_ENABLE
= FALSE
410 echo PYTHON_COMMAND
= %PYTHON_COMMAND%
412 echo PYTHONPATH
= %PYTHONPATH%
415 :VisualStudioAvailable
416 if not defined FORCE_REBUILD
(
417 if not defined REBUILD
(
422 if not defined VCINSTALLDIR
(
424 @
echo !!! ERROR
!!!! Cannot
find Visual Studio
, required to build C tools
!!!
428 if not defined FORCE_REBUILD
goto IncrementalBuild
434 del /f
/q
%BASE_TOOLS_PATH%\Bin\Win32\
*.
*
436 @REM Let CleanAndBuild fall through to IncrementalBuild
449 echo !!! ERROR
!!! Cannot build BaseTools applications
- no source directory located
!!!
455 echo Usage
: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]"
457 @
echo base_tools_path BaseTools project
path, BASE_TOOLS_PATH will be
set to this
path.
458 @
echo edk_tools_path EDK_TOOLS_PATH will be
set to this
path.
459 @
echo Rebuild
If sources are available perform an Incremental build
, only
460 @
echo build those updated tools.
461 @
echo ForceRebuild
If sources are available
, rebuild all tools regardless of
462 @
echo whether they have been updated or
not.
463 @
echo Reconfig Reinstall target.txt
, tools_def.txt and build_rule.txt.
464 @
echo VS2012
Set the env
for VS2012 build.
465 @
echo VS2013
Set the env
for VS2013 build.
466 @
echo VS2015
Set the env
for VS2015 build.
467 @
echo VS2017
Set the env
for VS2017 build.
468 @
echo VS2019
Set the env
for VS2019 build.