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 - 2018, 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
15 @REM ##############################################################
16 @REM # You should
not have to modify anything below this line
19 if /I
"%1"=="-h" goto Usage
20 if /I
"%1"=="-help" goto Usage
21 if /I
"%1"=="--help" goto Usage
22 if /I
"%1"=="/h" goto Usage
23 if /I
"%1"=="/help" goto Usage
24 if /I
"%1"=="/?" goto Usage
28 if "%1"=="" goto setup_workspace
29 if /I
"%1"=="--nt32" (
33 @REM Ignore
--nt32 flag
37 if /I
"%1"=="Reconfig" (
42 if /I
"%1"=="Rebuild" (
47 if /I
"%1"=="ForceRebuild" (
49 set FORCE_REBUILD
=TRUE
52 if "%1"=="" goto setup_workspace
54 if not defined BASE_TOOLS_PATH
(
55 if exist %1\Source
set BASE_TOOLS_PATH
=%1
59 if not defined EDK_TOOLS_PATH
(
60 if exist %1\Bin\Win32
set EDK_TOOLS_PATH
=%1
65 echo !!! ERROR
!!! Unknown argument
, %1 !!!
70 echo !!! ERROR
!!! Unknown argument
, %1 !!!
78 @REM Check the required system environment variables
83 REM check the EDK_TOOLS_PATH
85 if not defined EDK_TOOLS_PATH
goto no_EDK_TOOLS_PATH
86 if exist %EDK_TOOLS_PATH% goto set_PATH
89 if not defined WORKSPACE
(
90 if defined BASE_TOOLS_PATH
(
91 set EDK_TOOLS_PATH
=%BASE_TOOLS_PATH%
95 echo !!! ERROR
!!! Neither BASE_TOOLS_PATH nor EDK_TOOLS_PATH are
set.
!!!
100 if exist %WORKSPACE%\BaseTools\Bin
(
101 set EDK_TOOLS_PATH
=%WORKSPACE%\BaseTools
105 echo !!! ERROR
!!! No tools
path available. Please
set EDK_TOOLS_PATH
!!!
112 if defined WORKSPACE_TOOLS_PATH
goto check_PATH
113 if not defined EDK_TOOLS_BIN
(
114 set EDK_TOOLS_BIN
=%EDK_TOOLS_PATH%\Bin\Win32
115 if not exist %EDK_TOOLS_PATH%\Bin\Win32
(
117 echo !!! ERROR
!!! Cannot
find BaseTools Bin Win32
!!!
118 echo Please check the directory
%EDK_TOOLS_PATH%\Bin\Win32
119 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
123 set PATH=%EDK_TOOLS_BIN%;%PATH%
124 set WORKSPACE_TOOLS_PATH
=%EDK_TOOLS_PATH%
128 if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok
129 if not defined EDK_TOOLS_BIN
(
130 set EDK_TOOLS_BIN
=%EDK_TOOLS_PATH%\Bin\Win32
131 if not exist %EDK_TOOLS_PATH%\Bin\Win32
(
133 echo !!! ERROR
!!! Cannot
find BaseTools Bin Win32
!!!
134 echo Please check the directory
%EDK_TOOLS_PATH%\Bin\Win32
135 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
139 set PATH=%EDK_TOOLS_BIN%;%PATH%
140 set WORKSPACE_TOOLS_PATH
=%EDK_TOOLS_PATH%
141 echo Resetting the
PATH variable to include the EDK_TOOLS_PATH
for this session.
145 REM copy *.template to %CONF_PATH%
147 if not defined WORKSPACE
(
148 if defined RECONFIG
(
150 echo !!! WARNING
!!! WORKSPACE environment variable was
not set, cannot Reconfig
!!!
156 IF NOT exist "%EDK_TOOLS_PATH%\set_vsprefix_envs.bat" (
158 @
echo !!! ERROR
!!! The set_vsprefix_envs.bat was
not found
!!!
162 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat
164 if not defined CONF_PATH
(
165 set CONF_PATH
=%WORKSPACE%\Conf
168 if NOT exist %CONF_PATH% (
169 if defined PACKAGES_PATH
(
170 for %%i IN
(%PACKAGES_PATH%) DO (
171 if exist %%~fi\Conf
(
172 set CONF_PATH
=%%i\Conf
180 if NOT exist %CONF_PATH% (
183 if defined RECONFIG
(
185 echo Over
-writing the
files in the CONF_PATH directory
186 echo using the default template
files
191 if NOT exist %CONF_PATH%\target.txt
(
192 echo copying ... target.template to
%CONF_PATH%\target.txt
193 if NOT exist %EDK_TOOLS_PATH%\Conf
\target.template
(
194 echo Error
: target.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
196 copy %EDK_TOOLS_PATH%\Conf
\target.template
%CONF_PATH%\target.txt
> nul
198 if defined RECONFIG
echo over
-write ... target.template to
%CONF_PATH%\target.txt
199 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\target.template
%CONF_PATH%\target.txt
> nul
202 if NOT exist %CONF_PATH%\tools_def.txt
(
203 echo copying ... tools_def.template to
%CONF_PATH%\tools_def.txt
204 if NOT exist %EDK_TOOLS_PATH%\Conf
\tools_def.template
(
205 echo Error
: tools_def.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
207 copy %EDK_TOOLS_PATH%\Conf
\tools_def.template
%CONF_PATH%\tools_def.txt
> nul
209 if defined RECONFIG
echo over
-write ... tools_def.template to
%CONF_PATH%\tools_def.txt
210 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\tools_def.template
%CONF_PATH%\tools_def.txt
> nul
213 if NOT exist %CONF_PATH%\build_rule.txt
(
214 echo copying ... build_rule.template to
%CONF_PATH%\build_rule.txt
215 if NOT exist %EDK_TOOLS_PATH%\Conf
\build_rule.template
(
216 echo Error
: build_rule.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
218 copy %EDK_TOOLS_PATH%\Conf
\build_rule.template
%CONF_PATH%\build_rule.txt
> nul
220 if defined RECONFIG
echo over
-write ... build_rule.template to
%CONF_PATH%\build_rule.txt
221 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\build_rule.template
%CONF_PATH%\build_rule.txt
> nul
226 if defined WORKSPACE
(
227 echo WORKSPACE
= %WORKSPACE%
229 if defined PACKAGES_PATH
(
230 echo PACKAGES_PATH
= %PACKAGES_PATH%
232 echo EDK_TOOLS_PATH
= %EDK_TOOLS_PATH%
233 if defined BASE_TOOLS_PATH
(
234 echo BASE_TOOLS_PATH
= %BASE_TOOLS_PATH%
236 if defined EDK_TOOLS_BIN
(
237 echo EDK_TOOLS_BIN
= %EDK_TOOLS_BIN%
239 echo CONF_PATH
= %CONF_PATH%
245 @REM Test
if we are going to have to
do a build
247 if defined FORCE_REBUILD
goto check_build_environment
248 if defined REBUILD
goto check_build_environment
249 if not exist "%EDK_TOOLS_PATH%" goto check_build_environment
250 if not exist "%EDK_TOOLS_BIN%" goto check_build_environment
252 IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools
253 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools
254 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools
255 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools
256 IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools
257 IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools
258 IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools
259 IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools
260 IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools
262 goto check_build_environment
266 echo !!! ERROR
!!! Binary C tools are missing. They are required to be built from BaseTools Source.
269 :check_build_environment
272 if not defined BASE_TOOLS_PATH
(
273 if not exist "Source\C\Makefile" (
274 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files
275 set BASE_TOOLS_PATH
=%EDK_TOOLS_PATH%
277 set BASE_TOOLS_PATH
=%CD%
282 if defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
283 goto check_python_available
285 if defined PYTHON3_ENABLE
(
286 if "%PYTHON3_ENABLE%" EQU
"TRUE" (
287 set PYTHON_COMMAND
=py
-3
288 goto check_python_available
293 if not defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
294 set PYTHON_COMMAND
=py
-3
295 py
-3 %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
296 setlocal enabledelayedexpansion
297 set /p PythonCheck
=<"PythonCheck.txt"
299 if "!PythonCheck!" NEQ "TRUE" (
300 if not defined PYTHON_HOME
if not defined PYTHONHOME
(
304 echo !!! ERROR
!!! Binary python tools are missing.
305 echo PYTHON_COMMAND
, PYTHON3_ENABLE or PYTHON_HOME
306 echo Environment variable is
not set successfully.
307 echo They is required to build or execute the python tools.
314 goto check_freezer_path
320 if defined PYTHON_HOME
(
321 if EXIST "%PYTHON_HOME%" (
322 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
323 goto check_python_available
326 if defined PYTHONHOME
(
327 if EXIST "%PYTHONHOME%" (
328 set PYTHON_HOME
=%PYTHONHOME%
329 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
330 goto check_python_available
334 echo !!! ERROR
!!! PYTHON_HOME is
not defined or The value of this variable does
not exist
337 :check_python_available
338 %PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
339 setlocal enabledelayedexpansion
340 set /p PythonCheck
=<"PythonCheck.txt"
342 if "!PythonCheck!" NEQ "TRUE" (
344 echo ! ERROR
! "%PYTHON_COMMAND%" is
not installed or added to environment variables
348 goto check_freezer_path
353 if defined BASETOOLS_PYTHON_SOURCE
goto print_python_info
354 set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"
355 set BASETOOLS_PYTHON_SOURCE
=%BASE_TOOLS_PATH%\Source\Python
356 set PYTHONPATH
=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
360 if defined PYTHON3_ENABLE
if "%PYTHON3_ENABLE%" EQU
"TRUE" (
361 echo PYTHON3_ENABLE
= %PYTHON3_ENABLE%
362 echo PYTHON3
= %PYTHON_COMMAND%
364 echo PYTHON3_ENABLE
= FALSE
365 echo PYTHON_COMMAND
= %PYTHON_COMMAND%
367 echo PYTHONPATH
= %PYTHONPATH%
370 :VisualStudioAvailable
371 if not defined FORCE_REBUILD
(
372 if not defined REBUILD
(
376 call "%EDK_TOOLS_PATH%\get_vsvars.bat"
377 if not defined VCINSTALLDIR
(
379 @
echo !!! ERROR
!!!! Cannot
find Visual Studio
, required to build C tools
!!!
383 if not defined FORCE_REBUILD
goto IncrementalBuild
389 del /f
/q
%BASE_TOOLS_PATH%\Bin\Win32\
*.
*
391 @REM Let CleanAndBuild fall through to IncrementalBuild
404 echo !!! ERROR
!!! Cannot build BaseTools applications
- no source directory located
!!!
410 echo Usage
: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"
412 @
echo base_tools_path BaseTools project
path, BASE_TOOLS_PATH will be
set to this
path.
413 @
echo edk_tools_path EDK_TOOLS_PATH will be
set to this
path.
414 @
echo Rebuild
If sources are available perform an Incremental build
, only
415 @
echo build those updated tools.
416 @
echo ForceRebuild
If sources are available
, rebuild all tools regardless of
417 @
echo whether they have been updated or
not.
418 @
echo Reconfig Reinstall target.txt
, tools_def.txt and build_rule.txt.