blob: 59874c58392f7eab3edf8e72ed8e3ca658737ff0 [file] [log] [blame]
lhauch8014e7c2008-02-22 16:31:23 +00001@REM @file
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.
jljusten07a756b2007-10-17 01:54:36 +00005@REM
Liming Gao4afd3d02013-08-23 02:18:16 +00006@REM Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
lhauch8014e7c2008-02-22 16:31:23 +00007@REM
8@REM This program and the accompanying materials are licensed and made available
Liming Gao4afd3d02013-08-23 02:18:16 +00009@REM under the terms and conditions of the BSD License which accompanies this
lhauch8014e7c2008-02-22 16:31:23 +000010@REM distribution. The full text of the license may be found at:
11@REM http://opensource.org/licenses/bsd-license.php
jljusten07a756b2007-10-17 01:54:36 +000012@REM
13@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
lhauch8014e7c2008-02-22 16:31:23 +000014@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
15@REM IMPLIED.
jljusten07a756b2007-10-17 01:54:36 +000016@REM
17
18@echo off
lhauch8014e7c2008-02-22 16:31:23 +000019pushd .
jljusten07a756b2007-10-17 01:54:36 +000020
lhauch8014e7c2008-02-22 16:31:23 +000021@REM ##############################################################
22@REM # You should not have to modify anything below this line
23@REM #
jljusten07a756b2007-10-17 01:54:36 +000024
Gao, Liminge4ac8702014-07-01 07:10:10 +000025if /I "%1"=="-h" goto Usage
26if /I "%1"=="-help" goto Usage
27if /I "%1"=="--help" goto Usage
28if /I "%1"=="/h" goto Usage
29if /I "%1"=="/help" goto Usage
30if /I "%1"=="/?" goto Usage
jljusten07a756b2007-10-17 01:54:36 +000031
jljusten07a756b2007-10-17 01:54:36 +000032
lhauch8014e7c2008-02-22 16:31:23 +000033:loop
Gao, Liminge4ac8702014-07-01 07:10:10 +000034 if "%1"=="" goto setup_workspace
35 if /I "%1"=="--nt32" (
lhauch8014e7c2008-02-22 16:31:23 +000036 @REM Ignore --nt32 flag
37 shift
38 goto loop
39 )
Gao, Liminge4ac8702014-07-01 07:10:10 +000040 if /I "%1"=="Reconfig" (
lhauch8014e7c2008-02-22 16:31:23 +000041 shift
42 set RECONFIG=TRUE
43 goto loop
44 )
Gao, Liminge4ac8702014-07-01 07:10:10 +000045 if /I "%1"=="Rebuild" (
lhauch8014e7c2008-02-22 16:31:23 +000046 shift
47 set REBUILD=TRUE
48 goto loop
49 )
Gao, Liminge4ac8702014-07-01 07:10:10 +000050 if /I "%1"=="ForceRebuild" (
lhauch8014e7c2008-02-22 16:31:23 +000051 shift
52 set FORCE_REBUILD=TRUE
53 goto loop
54 )
55 if "%1"=="" goto setup_workspace
56 if exist %1 (
57 if not defined BASE_TOOLS_PATH (
58 if exist %1\Source set BASE_TOOLS_PATH=%1
59 shift
60 goto loop
61 )
62 if not defined EDK_TOOLS_PATH (
63 if exist %1\Bin\Win32 set EDK_TOOLS_PATH=%1
64 shift
65 goto loop
66 )
67 echo.
68 echo !!! ERROR !!! Unknown argument, %1 !!!
69 echo.
70 goto end
71 ) else (
72 echo.
73 echo !!! ERROR !!! Unknown argument, %1 !!!
74 echo.
75 goto end
76 )
77 goto loop
78
79
80@REM
81@REM Check the required system environment variables
82@REM
jljusten07a756b2007-10-17 01:54:36 +000083
84:setup_workspace
lhauch8014e7c2008-02-22 16:31:23 +000085 REM
86 REM check the EDK_TOOLS_PATH
87 REM
88 if not defined EDK_TOOLS_PATH goto no_EDK_TOOLS_PATH
89 if exist %EDK_TOOLS_PATH% goto set_PATH
jljusten07a756b2007-10-17 01:54:36 +000090
lhauch8014e7c2008-02-22 16:31:23 +000091:no_EDK_TOOLS_PATH
92 if not defined WORKSPACE (
93 if defined BASE_TOOLS_PATH (
94 set EDK_TOOLS_PATH=%BASE_TOOLS_PATH%
95 goto set_PATH
96 ) else (
97 echo.
98 echo !!! ERROR !!! Neither BASE_TOOLS_PATH nor EDK_TOOLS_PATH are set. !!!
99 echo.
100 goto end
101 )
102 ) else (
103 if exist %WORKSPACE%\BaseTools\Bin (
104 set EDK_TOOLS_PATH=%WORKSPACE%\BaseTools
105 goto set_PATH
106 ) else (
107 echo.
108 echo !!! ERROR !!! No tools path available. Please set EDK_TOOLS_PATH !!!
109 echo.
110 goto end
111 )
112 )
113
114:set_PATH
115 if defined WORKSPACE_TOOLS_PATH goto check_PATH
Liming Gaodcc80782015-10-08 09:29:09 +0000116 if not defined EDK_TOOLS_BIN (
117 if exist %EDK_TOOLS_PATH%\Bin\Win32 (
118 set EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32
119 ) else (
120 echo.
121 echo !!! ERROR !!! Cannot find BaseTools Bin Win32!!!
122 echo Please check the directory %EDK_TOOLS_PATH%\Bin\Win32
123 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
124 echo.
125 goto end
126 )
127 )
128 set PATH=%EDK_TOOLS_BIN%;%PATH%
lhauch8014e7c2008-02-22 16:31:23 +0000129 set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%
130 goto PATH_ok
131
132:check_PATH
133 if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok
Liming Gaodcc80782015-10-08 09:29:09 +0000134 if not defined EDK_TOOLS_BIN (
135 if exist %EDK_TOOLS_PATH%\Bin\Win32 (
136 set EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32
137 ) else (
138 echo.
139 echo !!! ERROR !!! Cannot find BaseTools Bin Win32!!!
140 echo Please check the directory %EDK_TOOLS_PATH%\Bin\Win32
141 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.
142 echo.
143 goto end
144 )
145 )
146 set PATH=%EDK_TOOLS_BIN%;%PATH%
lhauch8014e7c2008-02-22 16:31:23 +0000147 set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%
148 echo Resetting the PATH variable to include the EDK_TOOLS_PATH for this session.
149
150:PATH_ok
jljusten07a756b2007-10-17 01:54:36 +0000151REM
Liming Gaodcc80782015-10-08 09:29:09 +0000152REM copy *.template to %CONF_PATH%
jljusten07a756b2007-10-17 01:54:36 +0000153REM
lhauch8014e7c2008-02-22 16:31:23 +0000154if not defined WORKSPACE (
155 if defined RECONFIG (
156 echo.
157 echo !!! WARNING !!! WORKSPACE environment variable was not set, cannot Reconfig !!!
158 echo.
159 )
160 goto skip_reconfig
161)
162
Liming Gaodcc80782015-10-08 09:29:09 +0000163set CONF_PATH=%WORKSPACE%\Conf
164if NOT exist %CONF_PATH% (
165 if defined PACKAGES_PATH (
166 for %%i IN (%PACKAGES_PATH%) DO (
167 if exist %%~fi\Conf (
168 set CONF_PATH=%%i\Conf
169 goto CopyConf
170 )
171 )
172 )
173)
174
175:CopyConf
176if NOT exist %CONF_PATH% (
177 mkdir %CONF_PATH%
jljusten07a756b2007-10-17 01:54:36 +0000178) else (
lhauch8014e7c2008-02-22 16:31:23 +0000179 if defined RECONFIG (
jljusten07a756b2007-10-17 01:54:36 +0000180 echo.
Liming Gaodcc80782015-10-08 09:29:09 +0000181 echo Over-writing the files in the CONF_PATH directory
jljusten07a756b2007-10-17 01:54:36 +0000182 echo using the default template files
183 echo.
184 )
185)
lhauch8014e7c2008-02-22 16:31:23 +0000186
Liming Gaodcc80782015-10-08 09:29:09 +0000187if NOT exist %CONF_PATH%\target.txt (
188 echo copying ... target.template to %CONF_PATH%\target.txt
klu2884f6e72009-05-13 02:04:01 +0000189 if NOT exist %EDK_TOOLS_PATH%\Conf\target.template (
190 echo Error: target.template is missing at folder %EDK_TOOLS_PATH%\Conf\
191 )
Liming Gaodcc80782015-10-08 09:29:09 +0000192 copy %EDK_TOOLS_PATH%\Conf\target.template %CONF_PATH%\target.txt > nul
jljusten07a756b2007-10-17 01:54:36 +0000193) else (
Liming Gaodcc80782015-10-08 09:29:09 +0000194 if defined RECONFIG echo over-write ... target.template to %CONF_PATH%\target.txt
195 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\target.template %CONF_PATH%\target.txt > nul
jljusten07a756b2007-10-17 01:54:36 +0000196)
lhauch8014e7c2008-02-22 16:31:23 +0000197
Liming Gaodcc80782015-10-08 09:29:09 +0000198if NOT exist %CONF_PATH%\tools_def.txt (
199 echo copying ... tools_def.template to %CONF_PATH%\tools_def.txt
klu2884f6e72009-05-13 02:04:01 +0000200 if NOT exist %EDK_TOOLS_PATH%\Conf\tools_def.template (
201 echo Error: tools_def.template is missing at folder %EDK_TOOLS_PATH%\Conf\
202 )
Liming Gaodcc80782015-10-08 09:29:09 +0000203 copy %EDK_TOOLS_PATH%\Conf\tools_def.template %CONF_PATH%\tools_def.txt > nul
jljusten07a756b2007-10-17 01:54:36 +0000204) else (
Liming Gaodcc80782015-10-08 09:29:09 +0000205 if defined RECONFIG echo over-write ... tools_def.template to %CONF_PATH%\tools_def.txt
206 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\tools_def.template %CONF_PATH%\tools_def.txt > nul
jljusten07a756b2007-10-17 01:54:36 +0000207)
lhauch8014e7c2008-02-22 16:31:23 +0000208
Liming Gaodcc80782015-10-08 09:29:09 +0000209if NOT exist %CONF_PATH%\build_rule.txt (
210 echo copying ... build_rule.template to %CONF_PATH%\build_rule.txt
klu2884f6e72009-05-13 02:04:01 +0000211 if NOT exist %EDK_TOOLS_PATH%\Conf\build_rule.template (
212 echo Error: build_rule.template is missing at folder %EDK_TOOLS_PATH%\Conf\
213 )
Liming Gaodcc80782015-10-08 09:29:09 +0000214 copy %EDK_TOOLS_PATH%\Conf\build_rule.template %CONF_PATH%\build_rule.txt > nul
jljusten07a756b2007-10-17 01:54:36 +0000215) else (
Liming Gaodcc80782015-10-08 09:29:09 +0000216 if defined RECONFIG echo over-write ... build_rule.template to %CONF_PATH%\build_rule.txt
217 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\build_rule.template %CONF_PATH%\build_rule.txt > nul
jljusten07a756b2007-10-17 01:54:36 +0000218)
219
Liming Gaodcc80782015-10-08 09:29:09 +0000220echo PATH = %PATH%
221echo.
222if defined WORKSPACE (
223 echo WORKSPACE = %WORKSPACE%
224)
225if defined PACKAGES_PATH (
226 echo PACKAGES_PATH = %PACKAGES_PATH%
227)
228echo EDK_TOOLS_PATH = %EDK_TOOLS_PATH%
229if defined BASE_TOOLS_PATH (
230 echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%
231)
232if defined EDK_TOOLS_BIN (
233 echo EDK_TOOLS_BIN = %EDK_TOOLS_BIN%
234)
235echo CONF_PATH = %CONF_PATH%
236echo.
237
lhauch8014e7c2008-02-22 16:31:23 +0000238:skip_reconfig
jljusten07a756b2007-10-17 01:54:36 +0000239
lhauch8014e7c2008-02-22 16:31:23 +0000240@REM
241@REM Test if we are going to have to do a build
242@REM
243if defined FORCE_REBUILD goto check_build_environment
244if defined REBUILD goto check_build_environment
Liming Gaodcc80782015-10-08 09:29:09 +0000245if not exist "%EDK_TOOLS_PATH%" goto check_build_environment
lhauch8014e7c2008-02-22 16:31:23 +0000246
Liming Gaodcc80782015-10-08 09:29:09 +0000247IF NOT EXIST "%EDK_TOOLS_BIN%\BootSectImage.exe" goto check_build_environment
248IF NOT EXIST "%EDK_TOOLS_BIN%\build.exe" goto check_build_environment
249IF NOT EXIST "%EDK_TOOLS_BIN%\EfiLdrImage.exe" goto check_build_environment
250IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_build_environment
251IF NOT EXIST "%EDK_TOOLS_BIN%\GenBootSector.exe" goto check_build_environment
252IF NOT EXIST "%EDK_TOOLS_BIN%\GenFds.exe" goto check_build_environment
253IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_build_environment
254IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_build_environment
255IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_build_environment
256IF NOT EXIST "%EDK_TOOLS_BIN%\GenPage.exe" goto check_build_environment
257IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_build_environment
258IF NOT EXIST "%EDK_TOOLS_BIN%\GenVtf.exe" goto check_build_environment
259IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_build_environment
260IF NOT EXIST "%EDK_TOOLS_BIN%\TargetTool.exe" goto check_build_environment
261IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_build_environment
262IF NOT EXIST "%EDK_TOOLS_BIN%\Trim.exe" goto check_build_environment
263IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_build_environment
264IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_build_environment
lhauch8014e7c2008-02-22 16:31:23 +0000265
jljusten07a756b2007-10-17 01:54:36 +0000266goto end
267
lhauch8014e7c2008-02-22 16:31:23 +0000268:check_build_environment
269
270 if not defined FORCE_REBUILD (
271 echo.
272 echo Rebuilding of tools is not required. Binaries of the latest,
273 echo tested versions of the tools have been tested and included in the
274 echo EDK II repository.
275 echo.
lhauchad42b172008-02-22 16:37:53 +0000276 echo If you really want to build the tools, use the ForceRebuild option.
lhauch8014e7c2008-02-22 16:31:23 +0000277 echo.
278 goto end
279 )
280
281 if not defined BASE_TOOLS_PATH (
282 if not exist "Source\C\Makefile" (
283 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files
284 set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%
285 ) else (
286 set BASE_TOOLS_PATH=%CD%
287 )
288 )
289 set PATH=%BASE_TOOLS_PATH%\Bin\Win32;%PATH%
290
Gao, Liminge4ac8702014-07-01 07:10:10 +0000291 set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python
292 set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
lhauch8014e7c2008-02-22 16:31:23 +0000293
294 if not defined PYTHON_HOME (
295 if defined PYTHONHOME (
296 set PYTHON_HOME=%PYTHONHOME%
297 ) else (
298 echo.
vanjefffd171542009-09-11 03:14:43 +0000299 echo !!! ERROR !!! PYTHON_HOME is required to build or execute the tools, please set it. !!!
lhauch8014e7c2008-02-22 16:31:23 +0000300 echo.
301 goto end
302 )
303 )
304
305 @REM We have Python, now test for FreezePython application
306 if not defined PYTHON_FREEZER_PATH (
307 @REM see if we can find FreezePython.ex
308 if exist "%PYTHON_HOME%\Tools\cx_Freeze-3.0.3\FreezePython.exe" (
309 set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze-3.0.3
310 )
311 if exist "%PYTHON_HOME%\Tools\cx_Freeze\FreezePython.exe" (
312 set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze
313 )
314 if exist "C:\cx_Freeze\FreezePython.exe" (
315 set PYTHON_FREEZER_PATH=C:\cx_Freeze
316 )
317 if exist "C:\cx_Freeze-3.0.3" (
318 set PYTHON_FREEZER_PATH=C:\cx_Freeze-3.0.3
319 )
320 if not defined PYTHON_FREEZER_PATH (
321 echo.
322 echo !!! WARNING !!! Will not be able to compile Python programs to .exe
323 echo Will setup environment to run Python scripts directly.
324 echo.
Gao, Liminge4ac8702014-07-01 07:10:10 +0000325 set PATH=%BASETOOLS_PYTHON_SOURCE%\Trim;%PATH%
326 set PATH=%BASETOOLS_PYTHON_SOURCE%\GenFds;%PATH%
327 set PATH=%BASETOOLS_PYTHON_SOURCE%\build;%PATH%
lhauch8014e7c2008-02-22 16:31:23 +0000328 set PATHEXT=%PATHEXT%;.py
329 )
330 )
331
332 echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%
333 echo PYTHON_PATH = %PYTHON_PATH%
334 echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%
335 echo.
336
Gao, Liminge4ac8702014-07-01 07:10:10 +0000337 call "%EDK_TOOLS_PATH%\get_vsvars.bat"
338 if not defined VCINSTALLDIR (
339 @echo.
340 @echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!
341 @echo.
342 goto end
lhauch8014e7c2008-02-22 16:31:23 +0000343 )
344
345:VisualStudioAvailable
Gao, Liminge4ac8702014-07-01 07:10:10 +0000346 if not defined FORCE_REBUILD goto IncrementalBuild
lhauch8014e7c2008-02-22 16:31:23 +0000347
348:CleanAndBuild
349 pushd .
350 cd %BASE_TOOLS_PATH%
351 call nmake cleanall
352 del /f /q %BASE_TOOLS_PATH%\Bin\Win32\*.*
353 popd
354 @REM Let CleanAndBuild fall through to IncrementalBuild
355
356
357:IncrementalBuild
358 pushd .
359 cd %BASE_TOOLS_PATH%
360 call nmake c
361 popd
362
363 if defined PYTHON_FREEZER_PATH (
364 echo BUILDING PYTHON TOOLS
365 pushd .
366 cd %BASE_TOOLS_PATH%
367 call nmake python
368 popd
369 ) else (
370 echo.
371 echo !!! WARNING !!! Cannot make executable from Python code, executing python scripts instead !!!
372 echo.
373 )
374 goto end
375
376
377:no_source_files
378 echo.
379 echo !!! ERROR !!! Cannot build BaseTools applications - no source directory located !!!
380 echo.
381 goto end
382
383:Usage
Gao, Liminge4ac8702014-07-01 07:10:10 +0000384 @echo.
lhauch8014e7c2008-02-22 16:31:23 +0000385 echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"
Gao, Liminge4ac8702014-07-01 07:10:10 +0000386 @echo.
387 @echo base_tools_path BaseTools project path, BASE_TOOLS_PATH will be set to this path.
388 @echo edk_tools_path EDK_TOOLS_PATH will be set to this path.
389 @echo Rebuild If sources are available perform an Incremental build, only
390 @echo build those updated tools.
391 @echo ForceRebuild If sources are available, rebuild all tools regardless of
392 @echo whether they have been updated or not.
393 @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
394 @echo.
jljusten07a756b2007-10-17 01:54:36 +0000395
396:end
lhauch8014e7c2008-02-22 16:31:23 +0000397set REBUILD=
398set FORCE_REBUILD=
399set RECONFIG=
400popd
401