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