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
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"=="VS2017" (
51 if /I
"%1"=="VS2015" (
57 if /I
"%1"=="VS2013" (
63 if /I
"%1"=="VS2012" (
69 if "%1"=="" goto setup_workspace
71 if not defined BASE_TOOLS_PATH
(
72 if exist %1\Source
set BASE_TOOLS_PATH
=%1
76 if not defined EDK_TOOLS_PATH
(
77 if exist %1\Bin\Win32
set EDK_TOOLS_PATH
=%1
82 echo !!! ERROR
!!! Unknown argument
, %1 !!!
87 echo !!! ERROR
!!! Unknown argument
, %1 !!!
95 @REM Check the required system environment variables
100 REM check the EDK_TOOLS_PATH
102 if not defined EDK_TOOLS_PATH
goto no_EDK_TOOLS_PATH
103 if exist %EDK_TOOLS_PATH% goto set_PATH
106 if not defined WORKSPACE
(
107 if defined BASE_TOOLS_PATH
(
108 set EDK_TOOLS_PATH
=%BASE_TOOLS_PATH%
112 echo !!! ERROR
!!! Neither BASE_TOOLS_PATH nor EDK_TOOLS_PATH are
set.
!!!
117 if exist %WORKSPACE%\BaseTools\Bin
(
118 set EDK_TOOLS_PATH
=%WORKSPACE%\BaseTools
122 echo !!! ERROR
!!! No tools
path available. Please
set EDK_TOOLS_PATH
!!!
129 if defined WORKSPACE_TOOLS_PATH
goto check_PATH
130 if not defined EDK_TOOLS_BIN
(
131 set EDK_TOOLS_BIN
=%EDK_TOOLS_PATH%\Bin\Win32
132 if not exist %EDK_TOOLS_PATH%\Bin\Win32
(
134 echo !!! ERROR
!!! Cannot
find BaseTools Bin Win32
!!!
135 echo Please check the directory
%EDK_TOOLS_PATH%\Bin\Win32
136 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
140 set PATH=%EDK_TOOLS_BIN%;%PATH%
141 set WORKSPACE_TOOLS_PATH
=%EDK_TOOLS_PATH%
145 if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok
146 if not defined EDK_TOOLS_BIN
(
147 set EDK_TOOLS_BIN
=%EDK_TOOLS_PATH%\Bin\Win32
148 if not exist %EDK_TOOLS_PATH%\Bin\Win32
(
150 echo !!! ERROR
!!! Cannot
find BaseTools Bin Win32
!!!
151 echo Please check the directory
%EDK_TOOLS_PATH%\Bin\Win32
152 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
156 set PATH=%EDK_TOOLS_BIN%;%PATH%
157 set WORKSPACE_TOOLS_PATH
=%EDK_TOOLS_PATH%
158 echo Resetting the
PATH variable to include the EDK_TOOLS_PATH
for this session.
162 REM copy *.template to %CONF_PATH%
164 if not defined WORKSPACE
(
165 if defined RECONFIG
(
167 echo !!! WARNING
!!! WORKSPACE environment variable was
not set, cannot Reconfig
!!!
173 IF NOT exist "%EDK_TOOLS_PATH%\set_vsprefix_envs.bat" (
175 @
echo !!! ERROR
!!! The set_vsprefix_envs.bat was
not found
!!!
180 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2017
181 ) else if defined VS2015
(
182 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2015
183 call %EDK_TOOLS_PATH%\get_vsvars.bat VS2015
184 ) else if defined VS2013
(
185 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2013
186 call %EDK_TOOLS_PATH%\get_vsvars.bat VS2013
187 ) else if defined VS2012
(
188 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2012
189 call %EDK_TOOLS_PATH%\get_vsvars.bat VS2012
191 call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat
192 call %EDK_TOOLS_PATH%\get_vsvars.bat
194 if %SCRIPT_ERROR% NEQ 0 (
196 @
echo !!! ERROR
!!! %VSTool% is
not installed
!!!
201 if not defined CONF_PATH
(
202 set CONF_PATH
=%WORKSPACE%\Conf
205 if NOT exist %CONF_PATH% (
206 if defined PACKAGES_PATH
(
207 for %%i IN
(%PACKAGES_PATH%) DO (
208 if exist %%~fi\Conf
(
209 set CONF_PATH
=%%i\Conf
217 if NOT exist %CONF_PATH% (
220 if defined RECONFIG
(
222 echo Over
-writing the
files in the CONF_PATH directory
223 echo using the default template
files
228 if NOT exist %CONF_PATH%\target.txt
(
229 echo copying ... target.template to
%CONF_PATH%\target.txt
230 if NOT exist %EDK_TOOLS_PATH%\Conf
\target.template
(
231 echo Error
: target.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
233 copy %EDK_TOOLS_PATH%\Conf
\target.template
%CONF_PATH%\target.txt
> nul
235 if defined RECONFIG
echo over
-write ... target.template to
%CONF_PATH%\target.txt
236 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\target.template
%CONF_PATH%\target.txt
> nul
239 if NOT exist %CONF_PATH%\tools_def.txt
(
240 echo copying ... tools_def.template to
%CONF_PATH%\tools_def.txt
241 if NOT exist %EDK_TOOLS_PATH%\Conf
\tools_def.template
(
242 echo Error
: tools_def.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
244 copy %EDK_TOOLS_PATH%\Conf
\tools_def.template
%CONF_PATH%\tools_def.txt
> nul
246 if defined RECONFIG
echo over
-write ... tools_def.template to
%CONF_PATH%\tools_def.txt
247 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\tools_def.template
%CONF_PATH%\tools_def.txt
> nul
250 if NOT exist %CONF_PATH%\build_rule.txt
(
251 echo copying ... build_rule.template to
%CONF_PATH%\build_rule.txt
252 if NOT exist %EDK_TOOLS_PATH%\Conf
\build_rule.template
(
253 echo Error
: build_rule.template is missing at folder
%EDK_TOOLS_PATH%\Conf\
255 copy %EDK_TOOLS_PATH%\Conf
\build_rule.template
%CONF_PATH%\build_rule.txt
> nul
257 if defined RECONFIG
echo over
-write ... build_rule.template to
%CONF_PATH%\build_rule.txt
258 if defined RECONFIG
copy /Y
%EDK_TOOLS_PATH%\Conf
\build_rule.template
%CONF_PATH%\build_rule.txt
> nul
263 if defined WORKSPACE
(
264 echo WORKSPACE
= %WORKSPACE%
266 if defined PACKAGES_PATH
(
267 echo PACKAGES_PATH
= %PACKAGES_PATH%
269 echo EDK_TOOLS_PATH
= %EDK_TOOLS_PATH%
270 if defined BASE_TOOLS_PATH
(
271 echo BASE_TOOLS_PATH
= %BASE_TOOLS_PATH%
273 if defined EDK_TOOLS_BIN
(
274 echo EDK_TOOLS_BIN
= %EDK_TOOLS_BIN%
276 echo CONF_PATH
= %CONF_PATH%
282 @REM Test
if we are going to have to
do a build
284 if defined FORCE_REBUILD
goto check_build_environment
285 if defined REBUILD
goto check_build_environment
286 if not exist "%EDK_TOOLS_PATH%" goto check_build_environment
287 if not exist "%EDK_TOOLS_BIN%" goto check_build_environment
289 IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools
290 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools
291 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools
292 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools
293 IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools
294 IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools
295 IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools
296 IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools
297 IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools
299 goto check_build_environment
303 echo !!! ERROR
!!! Binary C tools are missing. They are required to be built from BaseTools Source.
306 :check_build_environment
309 if not defined BASE_TOOLS_PATH
(
310 if not exist "Source\C\Makefile" (
311 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files
312 set BASE_TOOLS_PATH
=%EDK_TOOLS_PATH%
314 set BASE_TOOLS_PATH
=%CD%
319 if defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
320 goto check_python_available
322 if defined PYTHON3_ENABLE
(
323 if "%PYTHON3_ENABLE%" EQU
"TRUE" (
324 set PYTHON_COMMAND
=py
-3
325 goto check_python_available
330 if not defined PYTHON_COMMAND
if not defined PYTHON3_ENABLE
(
331 set PYTHON_COMMAND
=py
-3
332 py
-3 %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
333 setlocal enabledelayedexpansion
334 set /p PythonCheck
=<"PythonCheck.txt"
336 if "!PythonCheck!" NEQ "TRUE" (
337 if not defined PYTHON_HOME
if not defined PYTHONHOME
(
341 echo !!! ERROR
!!! Binary python tools are missing.
342 echo PYTHON_COMMAND
, PYTHON3_ENABLE or PYTHON_HOME
343 echo Environment variable is
not set successfully.
344 echo They is required to build or execute the python tools.
351 goto check_freezer_path
357 if defined PYTHON_HOME
(
358 if EXIST "%PYTHON_HOME%" (
359 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
360 goto check_python_available
363 if defined PYTHONHOME
(
364 if EXIST "%PYTHONHOME%" (
365 set PYTHON_HOME
=%PYTHONHOME%
366 set PYTHON_COMMAND
=%PYTHON_HOME%\python.exe
367 goto check_python_available
371 echo !!! ERROR
!!! PYTHON_HOME is
not defined or The value of this variable does
not exist
374 :check_python_available
375 %PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py
>PythonCheck.txt
2>&1
376 setlocal enabledelayedexpansion
377 set /p PythonCheck
=<"PythonCheck.txt"
379 if "!PythonCheck!" NEQ "TRUE" (
381 echo ! ERROR
! "%PYTHON_COMMAND%" is
not installed or added to environment variables
385 goto check_freezer_path
390 if defined BASETOOLS_PYTHON_SOURCE
goto print_python_info
391 set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"
392 set BASETOOLS_PYTHON_SOURCE
=%BASE_TOOLS_PATH%\Source\Python
393 set PYTHONPATH
=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
397 if defined PYTHON3_ENABLE
if "%PYTHON3_ENABLE%" EQU
"TRUE" (
398 echo PYTHON3_ENABLE
= %PYTHON3_ENABLE%
399 echo PYTHON3
= %PYTHON_COMMAND%
401 echo PYTHON3_ENABLE
= FALSE
402 echo PYTHON_COMMAND
= %PYTHON_COMMAND%
404 echo PYTHONPATH
= %PYTHONPATH%
407 :VisualStudioAvailable
408 if not defined FORCE_REBUILD
(
409 if not defined REBUILD
(
414 if not defined VCINSTALLDIR
(
416 @
echo !!! ERROR
!!!! Cannot
find Visual Studio
, required to build C tools
!!!
420 if not defined FORCE_REBUILD
goto IncrementalBuild
426 del /f
/q
%BASE_TOOLS_PATH%\Bin\Win32\
*.
*
428 @REM Let CleanAndBuild fall through to IncrementalBuild
441 echo !!! ERROR
!!! Cannot build BaseTools applications
- no source directory located
!!!
447 echo Usage
: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]] [VS2017] [VS2015] [VS2013] [VS2012]"
449 @
echo base_tools_path BaseTools project
path, BASE_TOOLS_PATH will be
set to this
path.
450 @
echo edk_tools_path EDK_TOOLS_PATH will be
set to this
path.
451 @
echo Rebuild
If sources are available perform an Incremental build
, only
452 @
echo build those updated tools.
453 @
echo ForceRebuild
If sources are available
, rebuild all tools regardless of
454 @
echo whether they have been updated or
not.
455 @
echo Reconfig Reinstall target.txt
, tools_def.txt and build_rule.txt.
456 @
echo VS2012
Set the env
for VS2012 build.
457 @
echo VS2013
Set the env
for VS2013 build.
458 @
echo VS2015
Set the env
for VS2015 build.
459 @
echo VS2017
Set the env
for VS2017 build.