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