]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - BaseTools/toolsetup.bat
CryptoPkg CLANG35: add -std=c99 to dodge OpenSSL C atomics issue
[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 SPDX-License-Identifier: BSD-2-Clause-Patent\r
10@REM\r
11\r
12@echo off\r
13pushd .\r
14\r
15@REM ##############################################################\r
16@REM # You should not have to modify anything below this line\r
17@REM #\r
18\r
19if /I "%1"=="-h" goto Usage\r
20if /I "%1"=="-help" goto Usage\r
21if /I "%1"=="--help" goto Usage\r
22if /I "%1"=="/h" goto Usage\r
23if /I "%1"=="/help" goto Usage\r
24if /I "%1"=="/?" goto Usage\r
25\r
26\r
27:loop\r
28 if "%1"=="" goto setup_workspace\r
29 if /I "%1"=="--nt32" (\r
30 if /I "%2" == "X64" (\r
31 shift\r
32 )\r
33 @REM Ignore --nt32 flag\r
34 shift\r
35 goto loop\r
36 )\r
37 if /I "%1"=="Reconfig" (\r
38 shift\r
39 set RECONFIG=TRUE\r
40 goto loop\r
41 )\r
42 if /I "%1"=="Rebuild" (\r
43 shift\r
44 set REBUILD=TRUE\r
45 goto loop\r
46 )\r
47 if /I "%1"=="ForceRebuild" (\r
48 shift\r
49 set FORCE_REBUILD=TRUE\r
50 goto loop\r
51 )\r
52 if "%1"=="" goto setup_workspace\r
53 if exist %1 (\r
54 if not defined BASE_TOOLS_PATH (\r
55 if exist %1\Source set BASE_TOOLS_PATH=%1\r
56 shift\r
57 goto loop\r
58 )\r
59 if not defined EDK_TOOLS_PATH (\r
60 if exist %1\Bin\Win32 set EDK_TOOLS_PATH=%1\r
61 shift\r
62 goto loop\r
63 )\r
64 echo.\r
65 echo !!! ERROR !!! Unknown argument, %1 !!!\r
66 echo.\r
67 goto end\r
68 ) else (\r
69 echo.\r
70 echo !!! ERROR !!! Unknown argument, %1 !!!\r
71 echo.\r
72 goto end\r
73 )\r
74 goto loop\r
75\r
76\r
77@REM\r
78@REM Check the required system environment variables\r
79@REM\r
80\r
81:setup_workspace\r
82 REM\r
83 REM check the EDK_TOOLS_PATH\r
84 REM\r
85 if not defined EDK_TOOLS_PATH goto no_EDK_TOOLS_PATH\r
86 if exist %EDK_TOOLS_PATH% goto set_PATH\r
87\r
88:no_EDK_TOOLS_PATH\r
89 if not defined WORKSPACE (\r
90 if defined BASE_TOOLS_PATH (\r
91 set EDK_TOOLS_PATH=%BASE_TOOLS_PATH%\r
92 goto set_PATH\r
93 ) else (\r
94 echo.\r
95 echo !!! ERROR !!! Neither BASE_TOOLS_PATH nor EDK_TOOLS_PATH are set. !!!\r
96 echo.\r
97 goto end\r
98 )\r
99 ) else (\r
100 if exist %WORKSPACE%\BaseTools\Bin (\r
101 set EDK_TOOLS_PATH=%WORKSPACE%\BaseTools\r
102 goto set_PATH\r
103 ) else (\r
104 echo.\r
105 echo !!! ERROR !!! No tools path available. Please set EDK_TOOLS_PATH !!!\r
106 echo.\r
107 goto end\r
108 )\r
109 )\r
110\r
111:set_PATH\r
112 if defined WORKSPACE_TOOLS_PATH goto check_PATH\r
113 if not defined EDK_TOOLS_BIN (\r
114 set EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32\r
115 if not exist %EDK_TOOLS_PATH%\Bin\Win32 (\r
116 echo.\r
117 echo !!! ERROR !!! Cannot find BaseTools Bin Win32!!!\r
118 echo Please check the directory %EDK_TOOLS_PATH%\Bin\Win32\r
119 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.\r
120 echo.\r
121 )\r
122 )\r
123 set PATH=%EDK_TOOLS_BIN%;%PATH%\r
124 set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
125 goto PATH_ok\r
126\r
127:check_PATH\r
128 if "%EDK_TOOLS_PATH%"=="%WORKSPACE_TOOLS_PATH%" goto PATH_ok\r
129 if not defined EDK_TOOLS_BIN (\r
130 set EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32\r
131 if not exist %EDK_TOOLS_PATH%\Bin\Win32 (\r
132 echo.\r
133 echo !!! ERROR !!! Cannot find BaseTools Bin Win32!!!\r
134 echo Please check the directory %EDK_TOOLS_PATH%\Bin\Win32\r
135 echo Or configure EDK_TOOLS_BIN env to point Win32 directory.\r
136 echo.\r
137 )\r
138 )\r
139 set PATH=%EDK_TOOLS_BIN%;%PATH%\r
140 set WORKSPACE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
141 echo Resetting the PATH variable to include the EDK_TOOLS_PATH for this session.\r
142\r
143:PATH_ok\r
144REM\r
145REM copy *.template to %CONF_PATH%\r
146REM\r
147if not defined WORKSPACE (\r
148 if defined RECONFIG (\r
149 echo.\r
150 echo !!! WARNING !!! WORKSPACE environment variable was not set, cannot Reconfig !!!\r
151 echo.\r
152 )\r
153 goto skip_reconfig\r
154)\r
155\r
156IF NOT exist "%EDK_TOOLS_PATH%\set_vsprefix_envs.bat" (\r
157 @echo.\r
158 @echo !!! ERROR !!! The set_vsprefix_envs.bat was not found !!!\r
159 @echo.\r
160 goto end\r
161)\r
162call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat\r
163\r
164if not defined CONF_PATH (\r
165 set CONF_PATH=%WORKSPACE%\Conf\r
166)\r
167\r
168if NOT exist %CONF_PATH% (\r
169 if defined PACKAGES_PATH (\r
170 for %%i IN (%PACKAGES_PATH%) DO (\r
171 if exist %%~fi\Conf (\r
172 set CONF_PATH=%%i\Conf\r
173 goto CopyConf\r
174 )\r
175 )\r
176 )\r
177)\r
178\r
179:CopyConf\r
180if NOT exist %CONF_PATH% (\r
181 mkdir %CONF_PATH%\r
182) else (\r
183 if defined RECONFIG (\r
184 echo.\r
185 echo Over-writing the files in the CONF_PATH directory\r
186 echo using the default template files\r
187 echo.\r
188 )\r
189)\r
190\r
191if NOT exist %CONF_PATH%\target.txt (\r
192 echo copying ... target.template to %CONF_PATH%\target.txt\r
193 if NOT exist %EDK_TOOLS_PATH%\Conf\target.template (\r
194 echo Error: target.template is missing at folder %EDK_TOOLS_PATH%\Conf\\r
195 )\r
196 copy %EDK_TOOLS_PATH%\Conf\target.template %CONF_PATH%\target.txt > nul\r
197) else (\r
198 if defined RECONFIG echo over-write ... target.template to %CONF_PATH%\target.txt\r
199 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\target.template %CONF_PATH%\target.txt > nul\r
200)\r
201\r
202if NOT exist %CONF_PATH%\tools_def.txt (\r
203 echo copying ... tools_def.template to %CONF_PATH%\tools_def.txt\r
204 if NOT exist %EDK_TOOLS_PATH%\Conf\tools_def.template (\r
205 echo Error: tools_def.template is missing at folder %EDK_TOOLS_PATH%\Conf\\r
206 )\r
207 copy %EDK_TOOLS_PATH%\Conf\tools_def.template %CONF_PATH%\tools_def.txt > nul\r
208) else (\r
209 if defined RECONFIG echo over-write ... tools_def.template to %CONF_PATH%\tools_def.txt\r
210 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\tools_def.template %CONF_PATH%\tools_def.txt > nul\r
211)\r
212\r
213if NOT exist %CONF_PATH%\build_rule.txt (\r
214 echo copying ... build_rule.template to %CONF_PATH%\build_rule.txt\r
215 if NOT exist %EDK_TOOLS_PATH%\Conf\build_rule.template (\r
216 echo Error: build_rule.template is missing at folder %EDK_TOOLS_PATH%\Conf\\r
217 )\r
218 copy %EDK_TOOLS_PATH%\Conf\build_rule.template %CONF_PATH%\build_rule.txt > nul\r
219) else (\r
220 if defined RECONFIG echo over-write ... build_rule.template to %CONF_PATH%\build_rule.txt\r
221 if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\build_rule.template %CONF_PATH%\build_rule.txt > nul\r
222)\r
223\r
224echo PATH = %PATH%\r
225echo.\r
226if defined WORKSPACE (\r
227 echo WORKSPACE = %WORKSPACE%\r
228)\r
229if defined PACKAGES_PATH (\r
230 echo PACKAGES_PATH = %PACKAGES_PATH%\r
231)\r
232echo EDK_TOOLS_PATH = %EDK_TOOLS_PATH%\r
233if defined BASE_TOOLS_PATH (\r
234 echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%\r
235)\r
236if defined EDK_TOOLS_BIN (\r
237 echo EDK_TOOLS_BIN = %EDK_TOOLS_BIN%\r
238)\r
239echo CONF_PATH = %CONF_PATH%\r
240echo.\r
241\r
242:skip_reconfig\r
243\r
244@REM\r
245@REM Test if we are going to have to do a build\r
246@REM\r
247if defined FORCE_REBUILD goto check_build_environment\r
248if defined REBUILD goto check_build_environment\r
249if not exist "%EDK_TOOLS_PATH%" goto check_build_environment\r
250if not exist "%EDK_TOOLS_BIN%" goto check_build_environment\r
251\r
252IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools\r
253IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools\r
254IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools\r
255IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools\r
256IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools\r
257IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools\r
258IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools\r
259IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools\r
260IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools\r
261\r
262goto check_build_environment\r
263\r
264:check_c_tools\r
265 echo.\r
266 echo !!! ERROR !!! Binary C tools are missing. They are required to be built from BaseTools Source.\r
267 echo.\r
268\r
269:check_build_environment\r
270 set PYTHONHASHSEED=1\r
271\r
272 if not defined BASE_TOOLS_PATH (\r
273 if not exist "Source\C\Makefile" (\r
274 if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files\r
275 set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
276 ) else (\r
277 set BASE_TOOLS_PATH=%CD%\r
278 )\r
279 )\r
280\r
281:defined_python\r
282if defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
283 goto check_python_available\r
284)\r
285if defined PYTHON3_ENABLE (\r
286 if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
287 set PYTHON_COMMAND=py -3\r
288 goto check_python_available\r
289 ) else (\r
290 goto check_python2\r
291 )\r
292)\r
293if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
294 set PYTHON_COMMAND=py -3\r
295 py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
296 setlocal enabledelayedexpansion\r
297 set /p PythonCheck=<"PythonCheck.txt"\r
298 del PythonCheck.txt\r
299 if "!PythonCheck!" NEQ "TRUE" (\r
300 if not defined PYTHON_HOME if not defined PYTHONHOME (\r
301 endlocal\r
302 set PYTHON_COMMAND=\r
303 echo.\r
304 echo !!! ERROR !!! Binary python tools are missing.\r
305 echo PYTHON_COMMAND, PYTHON3_ENABLE or PYTHON_HOME\r
306 echo Environment variable is not set successfully.\r
307 echo They is required to build or execute the python tools.\r
308 echo.\r
309 goto end\r
310 ) else (\r
311 goto check_python2\r
312 )\r
313 ) else (\r
314 goto check_freezer_path\r
315 )\r
316)\r
317\r
318:check_python2\r
319endlocal\r
320if defined PYTHON_HOME (\r
321 if EXIST "%PYTHON_HOME%" (\r
322 set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
323 goto check_python_available\r
324 )\r
325)\r
326if defined PYTHONHOME (\r
327 if EXIST "%PYTHONHOME%" (\r
328 set PYTHON_HOME=%PYTHONHOME%\r
329 set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
330 goto check_python_available\r
331 )\r
332)\r
333echo.\r
334echo !!! ERROR !!! PYTHON_HOME is not defined or The value of this variable does not exist\r
335echo.\r
336goto end\r
337:check_python_available\r
338%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
339 setlocal enabledelayedexpansion\r
340 set /p PythonCheck=<"PythonCheck.txt"\r
341 del PythonCheck.txt\r
342 if "!PythonCheck!" NEQ "TRUE" (\r
343 echo.\r
344 echo ! ERROR ! "%PYTHON_COMMAND%" is not installed or added to environment variables\r
345 echo.\r
346 goto end\r
347 ) else (\r
348 goto check_freezer_path\r
349 )\r
350\r
351:check_freezer_path\r
352 endlocal\r
353 if defined BASETOOLS_PYTHON_SOURCE goto print_python_info\r
354 set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"\r
355 set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r
356 set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r
357\r
358:print_python_info\r
359 echo PATH = %PATH%\r
360 if defined PYTHON3_ENABLE if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
361 echo PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
362 echo PYTHON3 = %PYTHON_COMMAND%\r
363 ) else (\r
364 echo PYTHON3_ENABLE = FALSE\r
365 echo PYTHON_COMMAND = %PYTHON_COMMAND%\r
366 )\r
367 echo PYTHONPATH = %PYTHONPATH%\r
368 echo.\r
369\r
370:VisualStudioAvailable\r
371 if not defined FORCE_REBUILD (\r
372 if not defined REBUILD (\r
373 goto end\r
374 )\r
375 )\r
376 call "%EDK_TOOLS_PATH%\get_vsvars.bat"\r
377 if not defined VCINSTALLDIR (\r
378 @echo.\r
379 @echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!\r
380 @echo.\r
381 goto end\r
382 )\r
383 if not defined FORCE_REBUILD goto IncrementalBuild\r
384\r
385:CleanAndBuild\r
386 pushd .\r
387 cd %BASE_TOOLS_PATH%\r
388 call nmake cleanall\r
389 del /f /q %BASE_TOOLS_PATH%\Bin\Win32\*.*\r
390 popd\r
391 @REM Let CleanAndBuild fall through to IncrementalBuild\r
392\r
393\r
394:IncrementalBuild\r
395 pushd .\r
396 cd %BASE_TOOLS_PATH%\r
397 call nmake c\r
398 popd\r
399 goto end\r
400\r
401\r
402:no_source_files\r
403 echo.\r
404 echo !!! ERROR !!! Cannot build BaseTools applications - no source directory located !!!\r
405 echo.\r
406 goto end\r
407\r
408:Usage\r
409 @echo.\r
410 echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"\r
411 @echo.\r
412 @echo base_tools_path BaseTools project path, BASE_TOOLS_PATH will be set to this path.\r
413 @echo edk_tools_path EDK_TOOLS_PATH will be set to this path.\r
414 @echo Rebuild If sources are available perform an Incremental build, only\r
415 @echo build those updated tools.\r
416 @echo ForceRebuild If sources are available, rebuild all tools regardless of\r
417 @echo whether they have been updated or not.\r
418 @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.\r
419 @echo.\r
420\r
421:end\r
422set REBUILD=\r
423set FORCE_REBUILD=\r
424set RECONFIG=\r
425popd\r
426\r