]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - BaseTools/toolsetup.bat
BaseTools: Various typo
[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 - 2018, 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 set EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32\r
122 if not exist %EDK_TOOLS_PATH%\Bin\Win32 (\r
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
128 )\r
129 )\r
130 set PATH=%EDK_TOOLS_BIN%;%PATH%\r
131 set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
132 goto PATH_ok\r
133\r
134:check_PATH\r
135 if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok\r
136 if not defined EDK_TOOLS_BIN (\r
137 set EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32\r
138 if not exist %EDK_TOOLS_PATH%\Bin\Win32 (\r
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
144 )\r
145 )\r
146 set PATH=%EDK_TOOLS_BIN%;%PATH%\r
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
149\r
150:PATH_ok\r
151REM\r
152REM copy *.template to %CONF_PATH%\r
153REM\r
154if 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
163IF 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
169call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat\r
170\r
171if not defined CONF_PATH (\r
172 set CONF_PATH=%WORKSPACE%\Conf\r
173)\r
174\r
175if 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
181 )\r
182 )\r
183 )\r
184)\r
185\r
186:CopyConf\r
187if NOT exist %CONF_PATH% (\r
188 mkdir %CONF_PATH%\r
189) else (\r
190 if defined RECONFIG (\r
191 echo.\r
192 echo Over-writing the files in the CONF_PATH directory\r
193 echo using the default template files\r
194 echo.\r
195 )\r
196)\r
197\r
198if NOT exist %CONF_PATH%\target.txt (\r
199 echo copying ... target.template to %CONF_PATH%\target.txt\r
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
203 copy %EDK_TOOLS_PATH%\Conf\target.template %CONF_PATH%\target.txt > nul\r
204) else (\r
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
207)\r
208\r
209if NOT exist %CONF_PATH%\tools_def.txt (\r
210 echo copying ... tools_def.template to %CONF_PATH%\tools_def.txt\r
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
214 copy %EDK_TOOLS_PATH%\Conf\tools_def.template %CONF_PATH%\tools_def.txt > nul\r
215) else (\r
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
218)\r
219\r
220if NOT exist %CONF_PATH%\build_rule.txt (\r
221 echo copying ... build_rule.template to %CONF_PATH%\build_rule.txt\r
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
225 copy %EDK_TOOLS_PATH%\Conf\build_rule.template %CONF_PATH%\build_rule.txt > nul\r
226) else (\r
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
229)\r
230\r
231echo PATH = %PATH%\r
232echo.\r
233if defined WORKSPACE (\r
234 echo WORKSPACE = %WORKSPACE%\r
235)\r
236if defined PACKAGES_PATH (\r
237 echo PACKAGES_PATH = %PACKAGES_PATH%\r
238)\r
239echo EDK_TOOLS_PATH = %EDK_TOOLS_PATH%\r
240if defined BASE_TOOLS_PATH (\r
241 echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%\r
242)\r
243if defined EDK_TOOLS_BIN (\r
244 echo EDK_TOOLS_BIN = %EDK_TOOLS_BIN%\r
245)\r
246echo CONF_PATH = %CONF_PATH%\r
247echo.\r
248\r
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
254if defined FORCE_REBUILD goto check_build_environment\r
255if defined REBUILD goto check_build_environment\r
256if not exist "%EDK_TOOLS_PATH%" goto check_build_environment\r
257if not exist "%EDK_TOOLS_BIN%" goto check_build_environment\r
258\r
259IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools\r
260IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools\r
261IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools\r
262IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools\r
263IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools\r
264IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools\r
265IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools\r
266IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools\r
267IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools\r
268\r
269goto check_build_environment\r
270\r
271:check_c_tools\r
272 echo.\r
273 echo !!! ERROR !!! Binary C tools are missing. They are required to be built from BaseTools Source.\r
274 echo.\r
275\r
276:check_build_environment\r
277 set PYTHONHASHSEED=1\r
278\r
279 if not defined BASE_TOOLS_PATH (\r
280 if not exist "Source\C\Makefile" (\r
281 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files\r
282 set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
283 ) else (\r
284 set BASE_TOOLS_PATH=%CD%\r
285 )\r
286 )\r
287\r
288:defined_python\r
289if defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
290 goto check_python_available\r
291)\r
292if defined PYTHON3_ENABLE (\r
293 if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
294 set PYTHON_COMMAND=py -3\r
295 goto check_python_available\r
296 ) else (\r
297 goto check_python2\r
298 )\r
299)\r
300if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
301 set PYTHON_COMMAND=py -3\r
302 py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
303 setlocal enabledelayedexpansion\r
304 set /p PythonCheck=<"PythonCheck.txt"\r
305 del PythonCheck.txt\r
306 if "!PythonCheck!" NEQ "TRUE" (\r
307 if not defined PYTHON_HOME if not defined PYTHONHOME (\r
308 endlocal\r
309 set PYTHON_COMMAND=\r
310 echo.\r
311 echo !!! ERROR !!! Binary python tools are missing.\r
312 echo PYTHON_COMMAND, PYTHON3_ENABLE or PYTHON_HOME\r
313 echo Environment variable is not set successfully.\r
314 echo They is required to build or execute the python tools.\r
315 echo.\r
316 goto end\r
317 ) else (\r
318 goto check_python2\r
319 )\r
320 ) else (\r
321 goto check_freezer_path\r
322 )\r
323)\r
324\r
325:check_python2\r
326endlocal\r
327if defined PYTHON_HOME (\r
328 if EXIST "%PYTHON_HOME%" (\r
329 set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
330 goto check_python_available\r
331 )\r
332)\r
333if defined PYTHONHOME (\r
334 if EXIST "%PYTHONHOME%" (\r
335 set PYTHON_HOME=%PYTHONHOME%\r
336 set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
337 goto check_python_available\r
338 )\r
339)\r
340echo.\r
341echo !!! ERROR !!! PYTHON_HOME is not defined or The value of this variable does not exist\r
342echo.\r
343goto end\r
344:check_python_available\r
345%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
346 setlocal enabledelayedexpansion\r
347 set /p PythonCheck=<"PythonCheck.txt"\r
348 del PythonCheck.txt\r
349 if "!PythonCheck!" NEQ "TRUE" (\r
350 echo.\r
351 echo ! ERROR ! "%PYTHON_COMMAND%" is not installed or added to environment variables\r
352 echo.\r
353 goto end\r
354 ) else (\r
355 goto check_freezer_path\r
356 )\r
357\r
358:check_freezer_path\r
359 endlocal\r
360 if defined BASETOOLS_PYTHON_SOURCE goto print_python_info\r
361 set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"\r
362 set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r
363 set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r
364\r
365:print_python_info\r
366 echo PATH = %PATH%\r
367 if defined PYTHON3_ENABLE if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
368 echo PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
369 echo PYTHON3 = %PYTHON_COMMAND%\r
370 ) else (\r
371 echo PYTHON3_ENABLE = FALSE\r
372 echo PYTHON_COMMAND = %PYTHON_COMMAND%\r
373 )\r
374 echo PYTHONPATH = %PYTHONPATH%\r
375 echo.\r
376\r
377:VisualStudioAvailable\r
378 if not defined FORCE_REBUILD (\r
379 if not defined REBUILD (\r
380 goto end\r
381 )\r
382 )\r
383 call "%EDK_TOOLS_PATH%\get_vsvars.bat"\r
384 if not defined VCINSTALLDIR (\r
385 @echo.\r
386 @echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!\r
387 @echo.\r
388 goto end\r
389 )\r
390 if not defined FORCE_REBUILD goto IncrementalBuild\r
391\r
392:CleanAndBuild\r
393 pushd .\r
394 cd %BASE_TOOLS_PATH%\r
395 call nmake cleanall\r
396 del /f /q %BASE_TOOLS_PATH%\Bin\Win32\*.*\r
397 popd\r
398 @REM Let CleanAndBuild fall through to IncrementalBuild\r
399\r
400\r
401:IncrementalBuild\r
402 pushd .\r
403 cd %BASE_TOOLS_PATH%\r
404 call nmake c\r
405 popd\r
406 goto end\r
407\r
408\r
409:no_source_files\r
410 echo.\r
411 echo !!! ERROR !!! Cannot build BaseTools applications - no source directory located !!!\r
412 echo.\r
413 goto end\r
414\r
415:Usage\r
416 @echo.\r
417 echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"\r
418 @echo.\r
419 @echo base_tools_path BaseTools project path, BASE_TOOLS_PATH will be set to this path.\r
420 @echo edk_tools_path EDK_TOOLS_PATH will be set to this path.\r
421 @echo Rebuild If sources are available perform an Incremental build, only\r
422 @echo build those updated tools.\r
423 @echo ForceRebuild If sources are available, rebuild all tools regardless of\r
424 @echo whether they have been updated or not.\r
425 @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.\r
426 @echo.\r
427\r
428:end\r
429set REBUILD=\r
430set FORCE_REBUILD=\r
431set RECONFIG=\r
432popd\r
433\r