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