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