]>
Commit | Line | Data |
---|---|---|
8014e7ce | 1 | @REM @file\r |
2 | @REM This stand-alone program is typically called by the edksetup.bat file, \r | |
3 | @REM however it may be executed directly from the BaseTools project folder\r | |
4 | @REM if the file is not executed within a WORKSPACE\BaseTools folder.\r | |
07a756b9 | 5 | @REM\r |
4afd3d04 | 6 | @REM Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r |
8014e7ce | 7 | @REM\r |
8 | @REM This program and the accompanying materials are licensed and made available\r | |
4afd3d04 | 9 | @REM under the terms and conditions of the BSD License which accompanies this \r |
8014e7ce | 10 | @REM distribution. The full text of the license may be found at:\r |
11 | @REM http://opensource.org/licenses/bsd-license.php\r | |
07a756b9 | 12 | @REM\r |
13 | @REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
8014e7ce | 14 | @REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR \r |
15 | @REM IMPLIED.\r | |
07a756b9 | 16 | @REM\r |
17 | \r | |
18 | @echo off\r | |
8014e7ce | 19 | pushd .\r |
07a756b9 | 20 | \r |
8014e7ce | 21 | @REM ##############################################################\r |
22 | @REM # You should not have to modify anything below this line\r | |
23 | @REM #\r | |
07a756b9 | 24 | \r |
e4ac870f LG |
25 | if /I "%1"=="-h" goto Usage\r |
26 | if /I "%1"=="-help" goto Usage\r | |
27 | if /I "%1"=="--help" goto Usage\r | |
28 | if /I "%1"=="/h" goto Usage\r | |
29 | if /I "%1"=="/help" goto Usage\r | |
30 | if /I "%1"=="/?" goto Usage\r | |
07a756b9 | 31 | \r |
07a756b9 | 32 | \r |
8014e7ce | 33 | :loop\r |
e4ac870f LG |
34 | if "%1"=="" goto setup_workspace\r |
35 | if /I "%1"=="--nt32" (\r | |
8014e7ce | 36 | @REM Ignore --nt32 flag\r |
37 | shift\r | |
38 | goto loop\r | |
39 | )\r | |
e4ac870f | 40 | if /I "%1"=="Reconfig" (\r |
8014e7ce | 41 | shift\r |
42 | set RECONFIG=TRUE\r | |
43 | goto loop\r | |
44 | )\r | |
e4ac870f | 45 | if /I "%1"=="Rebuild" (\r |
8014e7ce | 46 | shift\r |
47 | set REBUILD=TRUE\r | |
48 | goto loop\r | |
49 | )\r | |
e4ac870f | 50 | if /I "%1"=="ForceRebuild" (\r |
8014e7ce | 51 | shift\r |
52 | set FORCE_REBUILD=TRUE\r | |
53 | goto loop\r | |
54 | )\r | |
55 | if "%1"=="" goto setup_workspace\r | |
56 | if exist %1 (\r | |
57 | if not defined BASE_TOOLS_PATH (\r | |
58 | if exist %1\Source set BASE_TOOLS_PATH=%1\r | |
59 | shift\r | |
60 | goto loop\r | |
61 | )\r | |
62 | if not defined EDK_TOOLS_PATH (\r | |
63 | if exist %1\Bin\Win32 set EDK_TOOLS_PATH=%1\r | |
64 | shift\r | |
65 | goto loop\r | |
66 | )\r | |
67 | echo.\r | |
68 | echo !!! ERROR !!! Unknown argument, %1 !!!\r | |
69 | echo.\r | |
70 | goto end\r | |
71 | ) else (\r | |
72 | echo.\r | |
73 | echo !!! ERROR !!! Unknown argument, %1 !!!\r | |
74 | echo.\r | |
75 | goto end\r | |
76 | )\r | |
77 | goto loop\r | |
78 | \r | |
79 | \r | |
80 | @REM\r | |
81 | @REM Check the required system environment variables\r | |
82 | @REM\r | |
07a756b9 | 83 | \r |
84 | :setup_workspace\r | |
8014e7ce | 85 | REM\r |
86 | REM check the EDK_TOOLS_PATH\r | |
87 | REM\r | |
88 | if not defined EDK_TOOLS_PATH goto no_EDK_TOOLS_PATH\r | |
89 | if exist %EDK_TOOLS_PATH% goto set_PATH\r | |
07a756b9 | 90 | \r |
8014e7ce | 91 | :no_EDK_TOOLS_PATH\r |
92 | if not defined WORKSPACE (\r | |
93 | if defined BASE_TOOLS_PATH (\r | |
94 | set EDK_TOOLS_PATH=%BASE_TOOLS_PATH%\r | |
95 | goto set_PATH\r | |
96 | ) else (\r | |
97 | echo.\r | |
98 | echo !!! ERROR !!! Neither BASE_TOOLS_PATH nor EDK_TOOLS_PATH are set. !!!\r | |
99 | echo.\r | |
100 | goto end\r | |
101 | )\r | |
102 | ) else (\r | |
103 | if exist %WORKSPACE%\BaseTools\Bin (\r | |
104 | set EDK_TOOLS_PATH=%WORKSPACE%\BaseTools\r | |
105 | goto set_PATH\r | |
106 | ) else (\r | |
107 | echo.\r | |
108 | echo !!! ERROR !!! No tools path available. Please set EDK_TOOLS_PATH !!!\r | |
109 | echo.\r | |
110 | goto end\r | |
111 | )\r | |
112 | )\r | |
07a756b9 | 113 | \r |
8014e7ce | 114 | :set_PATH\r |
115 | if defined WORKSPACE_TOOLS_PATH goto check_PATH\r | |
116 | set PATH=%EDK_TOOLS_PATH%\Bin;%EDK_TOOLS_PATH%\Bin\Win32;%PATH%\r | |
117 | set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%\r | |
118 | goto PATH_ok\r | |
07a756b9 | 119 | \r |
8014e7ce | 120 | :check_PATH\r |
121 | if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok\r | |
122 | set PATH=%EDK_TOOLS_PATH%\Bin;%EDK_TOOLS_PATH%\Bin\Win32;%PATH%\r | |
123 | set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%\r | |
124 | echo Resetting the PATH variable to include the EDK_TOOLS_PATH for this session.\r | |
07a756b9 | 125 | \r |
8014e7ce | 126 | :PATH_ok\r |
127 | echo PATH = %PATH%\r | |
128 | echo.\r | |
129 | if defined WORKSPACE (\r | |
130 | echo WORKSPACE = %WORKSPACE%\r | |
131 | )\r | |
132 | echo EDK_TOOLS_PATH = %EDK_TOOLS_PATH%\r | |
133 | if defined BASE_TOOLS_PATH (\r | |
9cf974f6 | 134 | echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%\r |
8014e7ce | 135 | )\r |
136 | echo.\r | |
07a756b9 | 137 | \r |
138 | REM\r | |
139 | REM copy *.template to %WORKSPACE%\Conf\r | |
140 | REM\r | |
8014e7ce | 141 | if not defined WORKSPACE (\r |
142 | if defined RECONFIG (\r | |
143 | echo.\r | |
144 | echo !!! WARNING !!! WORKSPACE environment variable was not set, cannot Reconfig !!!\r | |
145 | echo.\r | |
146 | )\r | |
147 | goto skip_reconfig\r | |
148 | )\r | |
149 | \r | |
07a756b9 | 150 | if NOT exist %WORKSPACE%\Conf (\r |
151 | mkdir %WORKSPACE%\Conf\r | |
152 | ) else (\r | |
8014e7ce | 153 | if defined RECONFIG (\r |
07a756b9 | 154 | echo.\r |
155 | echo Over-writing the files in the WORKSPACE\Conf directory\r | |
156 | echo using the default template files\r | |
157 | echo.\r | |
158 | )\r | |
159 | )\r | |
8014e7ce | 160 | \r |
07a756b9 | 161 | if NOT exist %WORKSPACE%\Conf\target.txt (\r |
162 | echo copying ... target.template to %WORKSPACE%\Conf\target.txt\r | |
884f6e76 | 163 | if NOT exist %EDK_TOOLS_PATH%\Conf\target.template (\r |
164 | echo Error: target.template is missing at folder %EDK_TOOLS_PATH%\Conf\\r | |
165 | )\r | |
07a756b9 | 166 | copy %EDK_TOOLS_PATH%\Conf\target.template %WORKSPACE%\Conf\target.txt > nul\r |
167 | ) else (\r | |
b6b554a1 | 168 | if defined RECONFIG echo over-write ... target.template to %WORKSPACE%\Conf\target.txt\r |
8014e7ce | 169 | if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\target.template %WORKSPACE%\Conf\target.txt > nul\r |
07a756b9 | 170 | )\r |
8014e7ce | 171 | \r |
07a756b9 | 172 | if NOT exist %WORKSPACE%\Conf\tools_def.txt (\r |
173 | echo copying ... tools_def.template to %WORKSPACE%\Conf\tools_def.txt\r | |
884f6e76 | 174 | if NOT exist %EDK_TOOLS_PATH%\Conf\tools_def.template (\r |
175 | echo Error: tools_def.template is missing at folder %EDK_TOOLS_PATH%\Conf\\r | |
176 | )\r | |
07a756b9 | 177 | copy %EDK_TOOLS_PATH%\Conf\tools_def.template %WORKSPACE%\Conf\tools_def.txt > nul\r |
178 | ) else (\r | |
b6b554a1 | 179 | if defined RECONFIG echo over-write ... tools_def.template to %WORKSPACE%\Conf\tools_def.txt\r |
8014e7ce | 180 | if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\tools_def.template %WORKSPACE%\Conf\tools_def.txt > nul\r |
07a756b9 | 181 | )\r |
8014e7ce | 182 | \r |
07a756b9 | 183 | if NOT exist %WORKSPACE%\Conf\build_rule.txt (\r |
184 | echo copying ... build_rule.template to %WORKSPACE%\Conf\build_rule.txt\r | |
884f6e76 | 185 | if NOT exist %EDK_TOOLS_PATH%\Conf\build_rule.template (\r |
186 | echo Error: build_rule.template is missing at folder %EDK_TOOLS_PATH%\Conf\\r | |
187 | )\r | |
07a756b9 | 188 | copy %EDK_TOOLS_PATH%\Conf\build_rule.template %WORKSPACE%\Conf\build_rule.txt > nul\r |
189 | ) else (\r | |
b6b554a1 | 190 | if defined RECONFIG echo over-write ... build_rule.template to %WORKSPACE%\Conf\build_rule.txt\r |
8014e7ce | 191 | if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\build_rule.template %WORKSPACE%\Conf\build_rule.txt > nul\r |
07a756b9 | 192 | )\r |
193 | \r | |
8014e7ce | 194 | :skip_reconfig\r |
195 | \r | |
196 | @REM\r | |
197 | @REM Test if we are going to have to do a build\r | |
198 | @REM\r | |
199 | if defined FORCE_REBUILD goto check_build_environment\r | |
200 | if defined REBUILD goto check_build_environment\r | |
201 | if not exist "%EDK_TOOLS_PATH%\Bin" goto check_build_environment\r | |
202 | \r | |
203 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\BootSectImage.exe" goto check_build_environment\r | |
204 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\build.exe" goto check_build_environment\r | |
205 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\EfiLdrImage.exe" goto check_build_environment\r | |
206 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\EfiRom.exe" goto check_build_environment\r | |
207 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenBootSector.exe" goto check_build_environment\r | |
208 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenFds.exe" goto check_build_environment\r | |
209 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenFfs.exe" goto check_build_environment\r | |
210 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenFv.exe" goto check_build_environment\r | |
211 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenFw.exe" goto check_build_environment\r | |
212 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenPage.exe" goto check_build_environment\r | |
213 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenSec.exe" goto check_build_environment\r | |
214 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\GenVtf.exe" goto check_build_environment\r | |
215 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\MigrationMsa2Inf.exe" goto check_build_environment\r | |
216 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\Split.exe" goto check_build_environment\r | |
217 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\TargetTool.exe" goto check_build_environment\r | |
218 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\TianoCompress.exe" goto check_build_environment\r | |
219 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\Trim.exe" goto check_build_environment\r | |
220 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\VfrCompile.exe" goto check_build_environment\r | |
221 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\Fpd2Dsc.exe" goto check_build_environment\r | |
222 | IF NOT EXIST "%EDK_TOOLS_PATH%\Bin\Win32\VolInfo.exe" goto check_build_environment\r | |
07a756b9 | 223 | \r |
07a756b9 | 224 | goto end\r |
225 | \r | |
8014e7ce | 226 | :check_build_environment\r |
227 | \r | |
228 | if not defined FORCE_REBUILD (\r | |
229 | echo.\r | |
230 | echo Rebuilding of tools is not required. Binaries of the latest,\r | |
231 | echo tested versions of the tools have been tested and included in the\r | |
232 | echo EDK II repository.\r | |
233 | echo.\r | |
ad42b17a | 234 | echo If you really want to build the tools, use the ForceRebuild option.\r |
8014e7ce | 235 | echo.\r |
236 | goto end\r | |
237 | )\r | |
238 | \r | |
239 | if not defined BASE_TOOLS_PATH (\r | |
240 | if not exist "Source\C\Makefile" (\r | |
241 | if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files\r | |
242 | set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%\r | |
243 | ) else (\r | |
244 | set BASE_TOOLS_PATH=%CD%\r | |
245 | )\r | |
246 | )\r | |
247 | set PATH=%BASE_TOOLS_PATH%\Bin\Win32;%PATH%\r | |
248 | \r | |
e4ac870f LG |
249 | set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r |
250 | set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r | |
8014e7ce | 251 | \r |
252 | if not defined PYTHON_HOME (\r | |
253 | if defined PYTHONHOME (\r | |
254 | set PYTHON_HOME=%PYTHONHOME%\r | |
255 | ) else (\r | |
256 | echo.\r | |
fd171542 | 257 | echo !!! ERROR !!! PYTHON_HOME is required to build or execute the tools, please set it. !!!\r |
8014e7ce | 258 | echo.\r |
259 | goto end\r | |
260 | )\r | |
261 | )\r | |
262 | \r | |
263 | @REM We have Python, now test for FreezePython application\r | |
264 | if not defined PYTHON_FREEZER_PATH (\r | |
265 | @REM see if we can find FreezePython.ex\r | |
266 | if exist "%PYTHON_HOME%\Tools\cx_Freeze-3.0.3\FreezePython.exe" (\r | |
267 | set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze-3.0.3\r | |
268 | ) \r | |
269 | if exist "%PYTHON_HOME%\Tools\cx_Freeze\FreezePython.exe" (\r | |
270 | set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze\r | |
271 | ) \r | |
272 | if exist "C:\cx_Freeze\FreezePython.exe" (\r | |
273 | set PYTHON_FREEZER_PATH=C:\cx_Freeze\r | |
274 | )\r | |
275 | if exist "C:\cx_Freeze-3.0.3" (\r | |
276 | set PYTHON_FREEZER_PATH=C:\cx_Freeze-3.0.3\r | |
277 | )\r | |
278 | if not defined PYTHON_FREEZER_PATH (\r | |
279 | echo.\r | |
280 | echo !!! WARNING !!! Will not be able to compile Python programs to .exe\r | |
281 | echo Will setup environment to run Python scripts directly.\r | |
282 | echo.\r | |
e4ac870f LG |
283 | set PATH=%BASETOOLS_PYTHON_SOURCE%\Trim;%PATH%\r |
284 | set PATH=%BASETOOLS_PYTHON_SOURCE%\GenFds;%PATH%\r | |
285 | set PATH=%BASETOOLS_PYTHON_SOURCE%\build;%PATH%\r | |
8014e7ce | 286 | set PATHEXT=%PATHEXT%;.py\r |
287 | )\r | |
288 | )\r | |
289 | \r | |
290 | echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%\r | |
291 | echo PYTHON_PATH = %PYTHON_PATH%\r | |
292 | echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%\r | |
293 | echo.\r | |
294 | \r | |
e4ac870f LG |
295 | call "%EDK_TOOLS_PATH%\get_vsvars.bat"\r |
296 | if not defined VCINSTALLDIR (\r | |
297 | @echo.\r | |
298 | @echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!\r | |
299 | @echo.\r | |
300 | goto end\r | |
8014e7ce | 301 | )\r |
302 | \r | |
303 | :VisualStudioAvailable\r | |
e4ac870f | 304 | if not defined FORCE_REBUILD goto IncrementalBuild\r |
8014e7ce | 305 | \r |
306 | :CleanAndBuild\r | |
307 | pushd .\r | |
308 | cd %BASE_TOOLS_PATH%\r | |
309 | call nmake cleanall\r | |
310 | del /f /q %BASE_TOOLS_PATH%\Bin\Win32\*.*\r | |
311 | popd\r | |
312 | @REM Let CleanAndBuild fall through to IncrementalBuild\r | |
313 | \r | |
314 | \r | |
315 | :IncrementalBuild\r | |
316 | pushd .\r | |
317 | cd %BASE_TOOLS_PATH%\r | |
318 | call nmake c\r | |
319 | popd\r | |
320 | \r | |
321 | if defined PYTHON_FREEZER_PATH (\r | |
322 | echo BUILDING PYTHON TOOLS\r | |
323 | pushd .\r | |
324 | cd %BASE_TOOLS_PATH%\r | |
325 | call nmake python\r | |
326 | popd\r | |
327 | ) else (\r | |
328 | echo.\r | |
329 | echo !!! WARNING !!! Cannot make executable from Python code, executing python scripts instead !!!\r | |
330 | echo.\r | |
331 | )\r | |
332 | goto end\r | |
333 | \r | |
334 | \r | |
335 | :no_source_files\r | |
336 | echo.\r | |
337 | echo !!! ERROR !!! Cannot build BaseTools applications - no source directory located !!!\r | |
338 | echo.\r | |
339 | goto end\r | |
340 | \r | |
341 | :Usage\r | |
e4ac870f | 342 | @echo.\r |
8014e7ce | 343 | echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"\r |
e4ac870f LG |
344 | @echo.\r |
345 | @echo base_tools_path BaseTools project path, BASE_TOOLS_PATH will be set to this path. \r | |
346 | @echo edk_tools_path EDK_TOOLS_PATH will be set to this path.\r | |
347 | @echo Rebuild If sources are available perform an Incremental build, only \r | |
348 | @echo build those updated tools.\r | |
349 | @echo ForceRebuild If sources are available, rebuild all tools regardless of \r | |
350 | @echo whether they have been updated or not.\r | |
351 | @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.\r | |
352 | @echo.\r | |
07a756b9 | 353 | \r |
354 | :end\r | |
8014e7ce | 355 | set REBUILD=\r |
356 | set FORCE_REBUILD=\r | |
357 | set RECONFIG=\r | |
358 | popd\r | |
359 | \r |