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