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"=="Reconfig" (
34 if /I
"%1"=="Rebuild" (
39 if /I
"%1"=="ForceRebuild" (
41 set FORCE_REBUILD
=TRUE
44 if "%1"=="" goto setup_workspace
46 if not defined BASE_TOOLS_PATH
(
47 if exist %1\Source
set BASE_TOOLS_PATH
=%1
51 if not defined EDK_TOOLS_PATH
(
52 if exist %1\Bin\Win32
set EDK_TOOLS_PATH
=%1
57 echo !!! ERROR
!!! Unknown argument
, %1 !!!
62 echo !!! ERROR
!!! Unknown argument
, %1 !!!
70 @REM Check the required system environment variables
75 REM check the EDK_TOOLS_PATH
77 if not defined EDK_TOOLS_PATH
goto no_EDK_TOOLS_PATH
78 if exist %EDK_TOOLS_PATH% goto set_PATH
81 if not defined WORKSPACE
(
82 if defined BASE_TOOLS_PATH
(
83 set EDK_TOOLS_PATH
=%BASE_TOOLS_PATH%
87 echo !!! ERROR
!!! Neither BASE_TOOLS_PATH nor EDK_TOOLS_PATH are
set.
!!!
92 if exist %WORKSPACE%\BaseTools\Bin
(
93 set EDK_TOOLS_PATH
=%WORKSPACE%\BaseTools
97 echo !!! ERROR
!!! No tools
path available. Please
set EDK_TOOLS_PATH
!!!
104 if defined WORKSPACE_TOOLS_PATH
goto check_PATH
105 if not defined EDK_TOOLS_BIN
(
106 set EDK_TOOLS_BIN
=%EDK_TOOLS_PATH%\Bin\Win32
107 if not exist %EDK_TOOLS_PATH%\Bin\Win32
(
109 echo !!! ERROR
!!! Cannot
find BaseTools Bin Win32
!!!
110 echo Please check the directory
%EDK_TOOLS_PATH%\Bin\Win32
111 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
115 set PATH=%EDK_TOOLS_BIN%;%PATH%
116 set WORKSPACE_TOOLS_PATH
=%EDK_TOOLS_PATH%
120 if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok
121 if not defined EDK_TOOLS_BIN
(
122 set EDK_TOOLS_BIN
=%EDK_TOOLS_PATH%\Bin\Win32
123 if not exist %EDK_TOOLS_PATH%\Bin\Win32
(
125 echo !!! ERROR
!!! Cannot
find BaseTools Bin Win32
!!!
126 echo Please check the directory
%EDK_TOOLS_PATH%\Bin\Win32
127 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
131 set PATH=%EDK_TOOLS_BIN%;%PATH%
132 set WORKSPACE_TOOLS_PATH
=%EDK_TOOLS_PATH%
133 echo Resetting the
PATH variable to include the EDK_TOOLS_PATH
for this session.
137 REM copy *.template to %CONF_PATH%
139 if not defined WORKSPACE
(
140 if defined RECONFIG
(
142 echo !!! WARNING
!!! WORKSPACE environment variable was
not set, cannot Reconfig
!!!
148 IF NOT exist "%EDK_TOOLS_PATH%\set_vsprefix_envs.bat" (
150 @
echo !!! ERROR
!!! The set_vsprefix_envs.bat was
not found
!!!
154 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat
156 if not defined CONF_PATH
(
157 set CONF_PATH
=%WORKSPACE%\Conf
160 if NOT exist %CONF_PATH% (
161 if defined PACKAGES_PATH
(
162 for %%i IN
(%PACKAGES_PATH%) DO (
163 if exist %%~fi\Conf
(
164 set CONF_PATH
=%%i\Conf
172 if NOT exist %CONF_PATH% (
175 if defined RECONFIG
(
177 echo Over
-writing the
files in the CONF_PATH directory
178 echo using the default template
files
183 if NOT exist %CONF_PATH%\target.txt
(
184 echo copying ... target.template to
%CONF_PATH%\target.txt
185 if NOT exist %EDK_TOOLS_PATH%\Conf
\target.template
(
186 echo Error
: target.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
188 copy %EDK_TOOLS_PATH%\Conf
\target.template
%CONF_PATH%\target.txt
> nul
190 if defined RECONFIG
echo over
-write ... target.template to
%CONF_PATH%\target.txt
191 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\target.template
%CONF_PATH%\target.txt
> nul
194 if NOT exist %CONF_PATH%\tools_def.txt
(
195 echo copying ... tools_def.template to
%CONF_PATH%\tools_def.txt
196 if NOT exist %EDK_TOOLS_PATH%\Conf
\tools_def.template
(
197 echo Error
: tools_def.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
199 copy %EDK_TOOLS_PATH%\Conf
\tools_def.template
%CONF_PATH%\tools_def.txt
> nul
201 if defined RECONFIG
echo over
-write ... tools_def.template to
%CONF_PATH%\tools_def.txt
202 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\tools_def.template
%CONF_PATH%\tools_def.txt
> nul
205 if NOT exist %CONF_PATH%\build_rule.txt
(
206 echo copying ... build_rule.template to
%CONF_PATH%\build_rule.txt
207 if NOT exist %EDK_TOOLS_PATH%\Conf
\build_rule.template
(
208 echo Error
: build_rule.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
210 copy %EDK_TOOLS_PATH%\Conf
\build_rule.template
%CONF_PATH%\build_rule.txt
> nul
212 if defined RECONFIG
echo over
-write ... build_rule.template to
%CONF_PATH%\build_rule.txt
213 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\build_rule.template
%CONF_PATH%\build_rule.txt
> nul
218 if defined WORKSPACE
(
219 echo WORKSPACE
= %WORKSPACE%
221 if defined PACKAGES_PATH
(
222 echo PACKAGES_PATH
= %PACKAGES_PATH%
224 echo EDK_TOOLS_PATH
= %EDK_TOOLS_PATH%
225 if defined BASE_TOOLS_PATH
(
226 echo BASE_TOOLS_PATH
= %BASE_TOOLS_PATH%
228 if defined EDK_TOOLS_BIN
(
229 echo EDK_TOOLS_BIN
= %EDK_TOOLS_BIN%
231 echo CONF_PATH
= %CONF_PATH%
237 @REM Test
if we are going to have to
do a build
239 if defined FORCE_REBUILD
goto check_build_environment
240 if defined REBUILD
goto check_build_environment
241 if not exist "%EDK_TOOLS_PATH%" goto check_build_environment
242 if not exist "%EDK_TOOLS_BIN%" goto check_build_environment
244 IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools
245 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools
246 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools
247 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools
248 IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools
249 IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools
250 IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools
251 IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools
252 IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools
254 goto check_build_environment
258 echo !!! ERROR
!!! Binary C tools are missing. They are required to be built from BaseTools Source.
261 :check_build_environment
264 if not defined BASE_TOOLS_PATH
(
265 if not exist "Source\C\Makefile" (
266 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files
267 set BASE_TOOLS_PATH
=%EDK_TOOLS_PATH%
269 set BASE_TOOLS_PATH
=%CD%
274 if defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
275 goto check_python_available
277 if defined PYTHON3_ENABLE
(
278 if "%PYTHON3_ENABLE%" EQU
"TRUE" (
279 set PYTHON_COMMAND
=py
-3
280 goto check_python_available
285 if not defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
286 set PYTHON_COMMAND
=py
-3
287 py
-3 %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
288 setlocal enabledelayedexpansion
289 set /p PythonCheck
=<"PythonCheck.txt"
291 if "!PythonCheck!" NEQ "TRUE" (
292 if not defined PYTHON_HOME
if not defined PYTHONHOME
(
296 echo !!! ERROR
!!! Binary python tools are missing.
297 echo PYTHON_COMMAND
, PYTHON3_ENABLE or PYTHON_HOME
298 echo Environment variable is
not set successfully.
299 echo They is required to build or execute the python tools.
306 goto check_freezer_path
312 if defined PYTHON_HOME
(
313 if EXIST "%PYTHON_HOME%" (
314 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
315 goto check_python_available
318 if defined PYTHONHOME
(
319 if EXIST "%PYTHONHOME%" (
320 set PYTHON_HOME
=%PYTHONHOME%
321 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
322 goto check_python_available
326 echo !!! ERROR
!!! PYTHON_HOME is
not defined or The value of this variable does
not exist
329 :check_python_available
330 %PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
331 setlocal enabledelayedexpansion
332 set /p PythonCheck
=<"PythonCheck.txt"
334 if "!PythonCheck!" NEQ "TRUE" (
336 echo ! ERROR
! "%PYTHON_COMMAND%" is
not installed or added to environment variables
340 goto check_freezer_path
345 if defined BASETOOLS_PYTHON_SOURCE
goto print_python_info
346 set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"
347 set BASETOOLS_PYTHON_SOURCE
=%BASE_TOOLS_PATH%\Source\Python
348 set PYTHONPATH
=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
352 if defined PYTHON3_ENABLE
if "%PYTHON3_ENABLE%" EQU
"TRUE" (
353 echo PYTHON3_ENABLE
= %PYTHON3_ENABLE%
354 echo PYTHON3
= %PYTHON_COMMAND%
356 echo PYTHON3_ENABLE
= FALSE
357 echo PYTHON_COMMAND
= %PYTHON_COMMAND%
359 echo PYTHONPATH
= %PYTHONPATH%
362 :VisualStudioAvailable
363 if not defined FORCE_REBUILD
(
364 if not defined REBUILD
(
368 call "%EDK_TOOLS_PATH%\get_vsvars.bat"
369 if not defined VCINSTALLDIR
(
371 @
echo !!! ERROR
!!!! Cannot
find Visual Studio
, required to build C tools
!!!
375 if not defined FORCE_REBUILD
goto IncrementalBuild
381 del /f
/q
%BASE_TOOLS_PATH%\Bin\Win32\
*.
*
383 @REM Let CleanAndBuild fall through to IncrementalBuild
396 echo !!! ERROR
!!! Cannot build BaseTools applications
- no source directory located
!!!
402 echo Usage
: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"
404 @
echo base_tools_path BaseTools project
path, BASE_TOOLS_PATH will be
set to this
path.
405 @
echo edk_tools_path EDK_TOOLS_PATH will be
set to this
path.
406 @
echo Rebuild
If sources are available perform an Incremental build
, only
407 @
echo build those updated tools.
408 @
echo ForceRebuild
If sources are available
, rebuild all tools regardless of
409 @
echo whether they have been updated or
not.
410 @
echo Reconfig Reinstall target.txt
, tools_def.txt and build_rule.txt.