blob: 561cc408cb7f30cbb0e0db517304f9c605be55e4 [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
lgao464b26092012-04-10 07:18:20 +00006@REM Copyright (c) 2006 - 2012, 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
9@REM under the terms and conditions of the BSD Licensewhich accompanies this
10@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
lhauch8014e7c2008-02-22 16:31:23 +000025@if /I "%1"=="-h" goto Usage
26@if /I "%1"=="-help" goto Usage
27@if /I "%1"=="--help" goto Usage
28@if /I "%1"=="/h" goto Usage
29@if /I "%1"=="/help" goto Usage
30@if /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
34 @if "%1"=="" goto setup_workspace
35 @if /I "%1"=="--nt32" (
36 @REM Ignore --nt32 flag
37 shift
38 goto loop
39 )
40 @if /I "%1"=="Reconfig" (
41 shift
42 set RECONFIG=TRUE
43 goto loop
44 )
45 @if /I "%1"=="Rebuild" (
46 shift
47 set REBUILD=TRUE
48 goto loop
49 )
50 @if /I "%1"=="ForceRebuild" (
51 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
116 set PATH=%EDK_TOOLS_PATH%\Bin;%EDK_TOOLS_PATH%\Bin\Win32;%PATH%
117 set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%
118 goto PATH_ok
119
120:check_PATH
121 if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok
122 set PATH=%EDK_TOOLS_PATH%\Bin;%EDK_TOOLS_PATH%\Bin\Win32;%PATH%
123 set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%
124 echo Resetting the PATH variable to include the EDK_TOOLS_PATH for this session.
125
126:PATH_ok
127 echo PATH = %PATH%
jljusten07a756b2007-10-17 01:54:36 +0000128 echo.
lhauch8014e7c2008-02-22 16:31:23 +0000129 if defined WORKSPACE (
130 echo WORKSPACE = %WORKSPACE%
131 )
132 echo EDK_TOOLS_PATH = %EDK_TOOLS_PATH%
133 if defined BASE_TOOLS_PATH (
lhauch9cf974f2008-06-11 22:01:53 +0000134 echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%
lhauch8014e7c2008-02-22 16:31:23 +0000135 )
jljusten07a756b2007-10-17 01:54:36 +0000136 echo.
jljusten07a756b2007-10-17 01:54:36 +0000137
138REM
139REM copy *.template to %WORKSPACE%\Conf
140REM
lhauch8014e7c2008-02-22 16:31:23 +0000141if not defined WORKSPACE (
142 if defined RECONFIG (
143 echo.
144 echo !!! WARNING !!! WORKSPACE environment variable was not set, cannot Reconfig !!!
145 echo.
146 )
147 goto skip_reconfig
148)
149
jljusten07a756b2007-10-17 01:54:36 +0000150if NOT exist %WORKSPACE%\Conf (
151 mkdir %WORKSPACE%\Conf
152) else (
lhauch8014e7c2008-02-22 16:31:23 +0000153 if defined RECONFIG (
jljusten07a756b2007-10-17 01:54:36 +0000154 echo.
155 echo Over-writing the files in the WORKSPACE\Conf directory
156 echo using the default template files
157 echo.
158 )
159)
lhauch8014e7c2008-02-22 16:31:23 +0000160
jljusten07a756b2007-10-17 01:54:36 +0000161if NOT exist %WORKSPACE%\Conf\target.txt (
162 echo copying ... target.template to %WORKSPACE%\Conf\target.txt
klu2884f6e72009-05-13 02:04:01 +0000163 if NOT exist %EDK_TOOLS_PATH%\Conf\target.template (
164 echo Error: target.template is missing at folder %EDK_TOOLS_PATH%\Conf\
165 )
jljusten07a756b2007-10-17 01:54:36 +0000166 copy %EDK_TOOLS_PATH%\Conf\target.template %WORKSPACE%\Conf\target.txt > nul
167) else (
lhauchb6b554a2009-01-08 16:58:03 +0000168 if defined RECONFIG echo over-write ... target.template to %WORKSPACE%\Conf\target.txt
lhauch8014e7c2008-02-22 16:31:23 +0000169 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\target.template %WORKSPACE%\Conf\target.txt > nul
jljusten07a756b2007-10-17 01:54:36 +0000170)
lhauch8014e7c2008-02-22 16:31:23 +0000171
jljusten07a756b2007-10-17 01:54:36 +0000172if NOT exist %WORKSPACE%\Conf\tools_def.txt (
173 echo copying ... tools_def.template to %WORKSPACE%\Conf\tools_def.txt
klu2884f6e72009-05-13 02:04:01 +0000174 if NOT exist %EDK_TOOLS_PATH%\Conf\tools_def.template (
175 echo Error: tools_def.template is missing at folder %EDK_TOOLS_PATH%\Conf\
176 )
jljusten07a756b2007-10-17 01:54:36 +0000177 copy %EDK_TOOLS_PATH%\Conf\tools_def.template %WORKSPACE%\Conf\tools_def.txt > nul
178) else (
lhauchb6b554a2009-01-08 16:58:03 +0000179 if defined RECONFIG echo over-write ... tools_def.template to %WORKSPACE%\Conf\tools_def.txt
lhauch8014e7c2008-02-22 16:31:23 +0000180 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\tools_def.template %WORKSPACE%\Conf\tools_def.txt > nul
jljusten07a756b2007-10-17 01:54:36 +0000181)
lhauch8014e7c2008-02-22 16:31:23 +0000182
jljusten07a756b2007-10-17 01:54:36 +0000183if NOT exist %WORKSPACE%\Conf\build_rule.txt (
184 echo copying ... build_rule.template to %WORKSPACE%\Conf\build_rule.txt
klu2884f6e72009-05-13 02:04:01 +0000185 if NOT exist %EDK_TOOLS_PATH%\Conf\build_rule.template (
186 echo Error: build_rule.template is missing at folder %EDK_TOOLS_PATH%\Conf\
187 )
jljusten07a756b2007-10-17 01:54:36 +0000188 copy %EDK_TOOLS_PATH%\Conf\build_rule.template %WORKSPACE%\Conf\build_rule.txt > nul
189) else (
lhauchb6b554a2009-01-08 16:58:03 +0000190 if defined RECONFIG echo over-write ... build_rule.template to %WORKSPACE%\Conf\build_rule.txt
lhauch8014e7c2008-02-22 16:31:23 +0000191 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\build_rule.template %WORKSPACE%\Conf\build_rule.txt > nul
jljusten07a756b2007-10-17 01:54:36 +0000192)
193
lhauch8014e7c2008-02-22 16:31:23 +0000194:skip_reconfig
jljusten07a756b2007-10-17 01:54:36 +0000195
lhauch8014e7c2008-02-22 16:31:23 +0000196@REM
197@REM Test if we are going to have to do a build
198@REM
199if defined FORCE_REBUILD goto check_build_environment
200if defined REBUILD goto check_build_environment
201if not exist "%EDK_TOOLS_PATH%\Bin" goto check_build_environment
202
203IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\BootSectImage.exe" goto check_build_environment
204IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\build.exe" goto check_build_environment
205IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\EfiLdrImage.exe" goto check_build_environment
206IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\EfiRom.exe" goto check_build_environment
207IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenBootSector.exe" goto check_build_environment
208IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenFds.exe" goto check_build_environment
209IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenFfs.exe" goto check_build_environment
210IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenFv.exe" goto check_build_environment
211IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenFw.exe" goto check_build_environment
212IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenPage.exe" goto check_build_environment
213IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenSec.exe" goto check_build_environment
214IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenVtf.exe" goto check_build_environment
215IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\MigrationMsa2Inf.exe" goto check_build_environment
216IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\Split.exe" goto check_build_environment
217IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\TargetTool.exe" goto check_build_environment
218IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\TianoCompress.exe" goto check_build_environment
219IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\Trim.exe" goto check_build_environment
220IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\VfrCompile.exe" goto check_build_environment
221IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\Fpd2Dsc.exe" goto check_build_environment
222IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\VolInfo.exe" goto check_build_environment
223
jljusten07a756b2007-10-17 01:54:36 +0000224goto end
225
lhauch8014e7c2008-02-22 16:31:23 +0000226:check_build_environment
227
228 if not defined FORCE_REBUILD (
229 echo.
230 echo Rebuilding of tools is not required. Binaries of the latest,
231 echo tested versions of the tools have been tested and included in the
232 echo EDK II repository.
233 echo.
lhauchad42b172008-02-22 16:37:53 +0000234 echo If you really want to build the tools, use the ForceRebuild option.
lhauch8014e7c2008-02-22 16:31:23 +0000235 echo.
236 goto end
237 )
238
239 if not defined BASE_TOOLS_PATH (
240 if not exist "Source\C\Makefile" (
241 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files
242 set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%
243 ) else (
244 set BASE_TOOLS_PATH=%CD%
245 )
246 )
247 set PATH=%BASE_TOOLS_PATH%\Bin\Win32;%PATH%
248
249 set PYTHONPATH=%BASE_TOOLS_PATH%\Source\Python
250
251 if not defined PYTHON_HOME (
252 if defined PYTHONHOME (
253 set PYTHON_HOME=%PYTHONHOME%
254 ) else (
255 echo.
vanjefffd171542009-09-11 03:14:43 +0000256 echo !!! ERROR !!! PYTHON_HOME is required to build or execute the tools, please set it. !!!
lhauch8014e7c2008-02-22 16:31:23 +0000257 echo.
258 goto end
259 )
260 )
261
262 @REM We have Python, now test for FreezePython application
263 if not defined PYTHON_FREEZER_PATH (
264 @REM see if we can find FreezePython.ex
265 if exist "%PYTHON_HOME%\Tools\cx_Freeze-3.0.3\FreezePython.exe" (
266 set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze-3.0.3
267 )
268 if exist "%PYTHON_HOME%\Tools\cx_Freeze\FreezePython.exe" (
269 set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze
270 )
271 if exist "C:\cx_Freeze\FreezePython.exe" (
272 set PYTHON_FREEZER_PATH=C:\cx_Freeze
273 )
274 if exist "C:\cx_Freeze-3.0.3" (
275 set PYTHON_FREEZER_PATH=C:\cx_Freeze-3.0.3
276 )
277 if not defined PYTHON_FREEZER_PATH (
278 echo.
279 echo !!! WARNING !!! Will not be able to compile Python programs to .exe
280 echo Will setup environment to run Python scripts directly.
281 echo.
282 set PYTHONPATH=%BASE_TOOLS_PATH%\Source\Python
283 set PATH=%PYTHONPATH%\build;%PYTHONPATH%\GenFds;%PYTHONPATH%\Trim;%PATH%
284 set PATHEXT=%PATHEXT%;.py
285 )
286 )
287
288 echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%
289 echo PYTHON_PATH = %PYTHON_PATH%
290 echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%
291 echo.
292
293 if defined VCINSTALLDIR goto VisualStudioAvailable
lgao464b26092012-04-10 07:18:20 +0000294 if defined VS100COMNTOOLS (
295 call "%VS100COMNTOOLS%\vsvars32.bat"
lhauch8014e7c2008-02-22 16:31:23 +0000296 ) else (
lgao464b26092012-04-10 07:18:20 +0000297 if defined VS90COMNTOOLS (
298 call "%VS90COMNTOOLS%\vsvars32.bat"
lhauch8014e7c2008-02-22 16:31:23 +0000299 ) else (
lgao464b26092012-04-10 07:18:20 +0000300 if defined VS80COMNTOOLS (
301 call "%VS80COMNTOOLS%\vsvars32.bat"
302 ) else (
303 if defined VS71COMNTOOLS (
304 call "%VS71COMNTOOLS%\vsvars32.bat"
305 ) else (
306 echo.
307 echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!
308 echo.
309 goto end
310 )
311 )
lhauch8014e7c2008-02-22 16:31:23 +0000312 )
313 )
314
315:VisualStudioAvailable
316 if defined FORCE_REBUILD goto CleanAndBuild
317 goto IncrementalBuild
318
319:CleanAndBuild
320 pushd .
321 cd %BASE_TOOLS_PATH%
322 call nmake cleanall
323 del /f /q %BASE_TOOLS_PATH%\Bin\Win32\*.*
324 popd
325 @REM Let CleanAndBuild fall through to IncrementalBuild
326
327
328:IncrementalBuild
329 pushd .
330 cd %BASE_TOOLS_PATH%
331 call nmake c
332 popd
333
334 if defined PYTHON_FREEZER_PATH (
335 echo BUILDING PYTHON TOOLS
336 pushd .
337 cd %BASE_TOOLS_PATH%
338 call nmake python
339 popd
340 ) else (
341 echo.
342 echo !!! WARNING !!! Cannot make executable from Python code, executing python scripts instead !!!
343 echo.
344 )
345 goto end
346
347
348:no_source_files
349 echo.
350 echo !!! ERROR !!! Cannot build BaseTools applications - no source directory located !!!
351 echo.
352 goto end
353
354:Usage
355 echo.
356 echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"
357 echo.
358 echo base_tools_path BaseTools project path, BASE_TOOLS_PATH will be set to this path.
359 echo edk_tools_path EDK_TOOLS_PATH will be set to this path.
360 echo Rebuild If sources are available perform an Incremental build, only
361 echo build those updated tools.
362 echo ForceRebuild If sources are available, rebuild all tools regardless of
363 echo whether they have been updated or not.
364 echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
jljusten07a756b2007-10-17 01:54:36 +0000365echo.
366
367:end
lhauch8014e7c2008-02-22 16:31:23 +0000368set REBUILD=
369set FORCE_REBUILD=
370set RECONFIG=
371popd
372
jljusten07a756b2007-10-17 01:54:36 +0000373@echo on
374