]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/bld_vlv.bat
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / Vlv2TbltDevicePkg / bld_vlv.bat
1 @REM @file
2 @REM Windows batch file to build BIOS ROM
3 @REM
4 @REM Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 @REM This program and the accompanying materials
6 @REM are licensed and made available under the terms and conditions of the BSD License
7 @REM which accompanies this distribution. The full text of the license may be found at
8 @REM http://opensource.org/licenses/bsd-license.php
9 @REM
10 @REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 @REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 @REM
13
14 @echo off
15 setlocal EnableDelayedExpansion EnableExtensions
16 echo.
17 echo %date% %time%
18 echo.
19
20 ::**********************************************************************
21 :: Initial Setup
22 ::**********************************************************************
23 REM set WORKSPACE=%CD%
24 REM if %WORKSPACE:~-1%==\ set WORKSPACE=%WORKSPACE:~0,-1%
25 set /a build_threads=1
26 set "Build_Flags= "
27 set exitCode=0
28 set Arch=X64
29 set Source=0
30
31 :: Clean up previous build files.
32 if exist %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.log del %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.log
33 if exist %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.report del %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.report
34 if exist %WORKSPACE%\unitool.log del %WORKSPACE%\unitool.log
35 if exist %WORKSPACE%\Conf\target.txt del %WORKSPACE%\Conf\target.txt
36 if exist %WORKSPACE%\Conf\tools_def.txt del %WORKSPACE%\Conf\tools_def.txt
37 if exist %WORKSPACE%\Conf\build_rule.txt del %WORKSPACE%\Conf\build_rule.txt
38 if exist %WORKSPACE%\Conf\FrameworkDatabase.db del %WORKSPACE%\Conf\FrameworkDatabase.db
39 if exist %WORKSPACE%\Conf\.cache rmdir /q/s %WORKSPACE%\Conf\.cache
40
41 :: Setup EDK environment. Edksetup puts new copies of target.txt, tools_def.txt, build_rule.txt in WorkSpace\Conf
42 :: Also run edksetup as soon as possible to avoid it from changing environment variables we're overriding
43 call edksetup.bat > nul
44 @echo off
45
46 :: Define platform specific environment variables.
47 set PLATFORM_PACKAGE=Vlv2TbltDevicePkg
48 set config_file=.\%PLATFORM_PACKAGE%\PlatformPkgConfig.dsc
49 set auto_config_inc=.\%PLATFORM_PACKAGE%\AutoPlatformCFG.txt
50
51 REM set EDK_SOURCE=%WORKSPACE%\EdkCompatibilityPkg
52
53 ::create new AutoPlatformCFG.txt file
54 copy /y nul %auto_config_inc% >nul
55
56 ::**********************************************************************
57 :: Parse command line arguments
58 ::**********************************************************************
59
60 :: Optional arguments
61 :OptLoop
62 if /i "%~1"=="/?" goto Usage
63
64 if /i "%~1"=="/l" (
65 set Build_Flags=%Build_Flags% -j %PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.log
66 shift
67 goto OptLoop
68 )
69 if /i "%~1"=="/y" (
70 set Build_Flags=%Build_Flags% -y %PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.report
71 shift
72 goto OptLoop
73 )
74 if /i "%~1"=="/m" (
75 if defined NUMBER_OF_PROCESSORS (
76 set /a build_threads=%NUMBER_OF_PROCESSORS%+1
77 )
78 shift
79 goto OptLoop
80 )
81 if /i "%~1" == "/c" (
82 echo Removing previous build files ...
83 if exist build (
84 del /f/s/q build > nul
85 rmdir /s/q build
86 )
87 if exist conf\.cache (
88 del /f/s/q conf\.cache > nul
89 rmdir /s/q conf\.cache
90 )
91 echo.
92 shift
93 goto OptLoop
94 )
95
96 if /i "%~1"=="/x64" (
97 set Arch=X64
98 shift
99 goto OptLoop
100 )
101 if /i "%~1"=="/IA32" (
102 set Arch=IA32
103 shift
104 goto OptLoop
105 )
106
107 :: Required argument(s)
108 if "%~1"=="" goto Usage
109
110 ::Remove the values for Platform_Type and Build_Target from BiosIdX.env and stage in Conf\
111 if "%Arch%"=="IA32" (
112 findstr /b /v "BOARD_ID BUILD_TYPE" %PLATFORM_PACKAGE%\BiosIdR.env > %WORKSPACE%\Conf\BiosId.env
113 echo DEFINE X64_CONFIG = FALSE >> %auto_config_inc%
114 ) else if "%Arch%"=="X64" (
115 findstr /b /v "BOARD_ID BUILD_TYPE" %PLATFORM_PACKAGE%\BiosIdx64R.env > %WORKSPACE%\Conf\BiosId.env
116 echo DEFINE X64_CONFIG = TRUE >> %auto_config_inc%
117 )
118
119 :: -- Build flags settings for each Platform --
120 echo Setting %1 platform configuration and BIOS ID...
121 if /i "%~1" == "MNW2" (
122 echo BOARD_ID = MNW2MAX >> %WORKSPACE%\Conf\BiosId.env
123 echo DEFINE ENBDT_PF_BUILD = TRUE >> %auto_config_inc%
124
125 ) else (
126 echo Error - Unsupported PlatformType: %1
127 goto Usage
128 )
129 set Platform_Type=%~1
130
131 if /i "%~2" == "RELEASE" (
132 set target=RELEASE
133 echo BUILD_TYPE = R >> %WORKSPACE%\Conf\BiosId.env
134 ) else (
135 set target=DEBUG
136 echo BUILD_TYPE = D >> %WORKSPACE%\Conf\BiosId.env
137 )
138
139 ::**********************************************************************
140 :: Additional EDK Build Setup/Configuration
141 ::**********************************************************************
142 echo.
143 echo Setting the Build environment for VS2008/VS2010/VS2012/VS2013...
144 if defined VS140COMNTOOLS (
145 if not defined VSINSTALLDIR call "%VS140COMNTOOLS%\vsvars32.bat"
146 if /I "%VS140COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 14.0\Common7\Tools\" (
147 set TOOL_CHAIN_TAG=VS2015
148 ) else (
149 set TOOL_CHAIN_TAG=VS2015x86
150 )
151 ) else if defined VS120COMNTOOLS (
152 if not defined VSINSTALLDIR call "%VS120COMNTOOLS%\vsvars32.bat"
153 if /I "%VS120COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\" (
154 set TOOL_CHAIN_TAG=VS2013
155 ) else (
156 set TOOL_CHAIN_TAG=VS2013x86
157 )
158 ) else if defined VS110COMNTOOLS (
159 if not defined VSINSTALLDIR call "%VS110COMNTOOLS%\vsvars32.bat"
160 if /I "%VS110COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 11.0\Common7\Tools\" (
161 set TOOL_CHAIN_TAG=VS2012
162 ) else (
163 set TOOL_CHAIN_TAG=VS2012x86
164 )
165 ) else if defined VS100COMNTOOLS (
166 if not defined VSINSTALLDIR call "%VS100COMNTOOLS%\vsvars32.bat"
167 if /I "%VS100COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\" (
168 set TOOL_CHAIN_TAG=VS2010
169 ) else (
170 set TOOL_CHAIN_TAG=VS2010x86
171 )
172 ) else if defined VS90COMNTOOLS (
173 if not defined VSINSTALLDIR call "%VS90COMNTOOLS%\vsvars32.bat"
174 if /I "%VS90COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\" (
175 set TOOL_CHAIN_TAG=VS2008
176 ) else (
177 set TOOL_CHAIN_TAG=VS2008x86
178 )
179 ) else (
180 echo --ERROR: VS2008/VS2010/VS2012/VS2013/VS2015 not installed correctly. VS90COMNTOOLS/VS100COMNTOOLS/VS110COMNTOOLS/VS120COMNTOOLS/VS140COMMONTOOLS not defined ^^!
181 echo.
182 goto :BldFail
183 )
184
185 echo Ensuring correct build directory is present for GenBiosId...
186 set BUILD_PATH=%WORKSPACE%\Build\%PLATFORM_PACKAGE%\%TARGET%_%TOOL_CHAIN_TAG%
187
188 echo Modifing Conf files for this build...
189 :: Remove lines with these tags from target.txt
190 findstr /V "TARGET TARGET_ARCH TOOL_CHAIN_TAG BUILD_RULE_CONF ACTIVE_PLATFORM MAX_CONCURRENT_THREAD_NUMBER" %WORKSPACE%\Conf\target.txt > %WORKSPACE%\Conf\target.txt.tmp
191
192 echo TARGET = %TARGET% >> %WORKSPACE%\Conf\target.txt.tmp
193 if "%Arch%"=="IA32" (
194 echo TARGET_ARCH = IA32 >> %WORKSPACE%\Conf\target.txt.tmp
195 ) else if "%Arch%"=="X64" (
196 echo TARGET_ARCH = IA32 X64 >> %WORKSPACE%\Conf\target.txt.tmp
197 )
198 echo TOOL_CHAIN_TAG = %TOOL_CHAIN_TAG% >> %WORKSPACE%\Conf\target.txt.tmp
199 echo BUILD_RULE_CONF = Conf/build_rule.txt >> %WORKSPACE%\Conf\target.txt.tmp
200 if %Source% == 0 (
201 echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE%/PlatformPkg%Arch%.dsc >> %WORKSPACE%\Conf\target.txt.tmp
202 ) else (
203 echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE%/PlatformPkg%Arch%Source.dsc >> %WORKSPACE%\Conf\target.txt.tmp
204 )
205 echo MAX_CONCURRENT_THREAD_NUMBER = %build_threads% >> %WORKSPACE%\Conf\target.txt.tmp
206
207 move /Y %WORKSPACE%\Conf\target.txt.tmp %WORKSPACE%\Conf\target.txt >nul
208
209 ::**********************************************************************
210 :: Build BIOS
211 ::**********************************************************************
212
213 echo Creating BiosId...
214 pushd %PLATFORM_PACKAGE%
215 if not exist %BUILD_PATH%\IA32 mkdir %BUILD_PATH%\IA32
216 GenBiosId.exe -i %WORKSPACE%\Conf\BiosId.env -o %BUILD_PATH%\IA32\BiosId.bin -ob %WORKSPACE%\Conf\BiosId.bat
217 if "%Arch%"=="X64" (
218 if not exist %BUILD_PATH%\X64 mkdir %BUILD_PATH%\X64
219 GenBiosId.exe -i %WORKSPACE%\Conf\BiosId.env -o %BUILD_PATH%\X64\BiosId.bin -ob %WORKSPACE%\Conf\BiosId.bat
220 )
221 popd
222
223
224 if %ERRORLEVEL% NEQ 0 goto BldFail
225
226 echo.
227 echo Invoking EDK2 build...
228 call build %Build_Flags%
229
230 if %ERRORLEVEL% NEQ 0 goto BldFail
231
232 ::**********************************************************************
233 :: Post Build processing and cleanup
234 ::**********************************************************************
235
236 echo Running fce...
237
238 pushd %PLATFORM_PACKAGE%
239 :: Extract Hii data from build and store in HiiDefaultData.txt
240 fce read -i %BUILD_PATH%\FV\Vlv.fd > %BUILD_PATH%\FV\HiiDefaultData.txt
241
242 :: save changes to VlvXXX.fd
243 fce update -i %BUILD_PATH%\FV\Vlv.fd -s %BUILD_PATH%\FV\HiiDefaultData.txt -o %BUILD_PATH%\FV\Vlv%Arch%.fd
244
245 popd
246
247 if %ERRORLEVEL% NEQ 0 goto BldFail
248 ::echo FD successfully updated with default Hii values.
249
250 :: Set the Board_Id, Build_Type, Version_Major, and Version_Minor environment variables
251 find /v "#" %WORKSPACE%\Conf\BiosId.env > ver_strings
252 for /f "tokens=1,3" %%i in (ver_strings) do set %%i=%%j
253 del /f/q ver_strings >nul
254
255 set BIOS_Name=%BOARD_ID%_%Arch%_%BUILD_TYPE%_%VERSION_MAJOR%_%VERSION_MINOR%.ROM
256 copy /y/b %BUILD_PATH%\FV\Vlv%Arch%.fd %WORKSPACE%\%BIOS_Name% >nul
257 copy /y/b %BUILD_PATH%\FV\Vlv%Arch%.fd %BUILD_PATH%\FV\Vlv.ROM >nul
258
259 echo.
260 echo Build location: %BUILD_PATH%
261 echo BIOS ROM Created: %BIOS_Name%
262 echo.
263 echo -------------------- The EDKII BIOS build has successfully completed. --------------------
264 echo.
265
266 @REM build capsule here
267 if "%openssl_path%" == "" (
268 echo -- Error: OPENSSL_PATH not set. Capule and Recovery images not generated.
269 set exitCode=1
270 goto Exit
271 )
272 echo > %BUILD_PATH%\FV\SYSTEMFIRMWAREUPDATECARGO.Fv
273 build -p %PLATFORM_PACKAGE%\PlatformCapsule.dsc
274
275 goto Exit
276
277 :Usage
278 echo.
279 echo ***************************************************************************
280 echo Build BIOS rom for VLV platforms.
281 echo.
282 echo Usage: bld_vlv.bat [options] PlatformType [Build Target]
283 echo.
284 echo /c CleanAll before building
285 echo /l Generate build log file
286 echo /y Generate build report file
287 echo /m Enable multi-processor build
288 echo /IA32 Set Arch to IA32 (default: X64)
289 echo /X64 Set Arch to X64 (default: X64)
290 echo.
291 echo Platform Types: MNW2
292 echo Build Targets: Debug, Release (default: Debug)
293 echo.
294 echo Examples:
295 echo bld_vlv.bat MNW2 : X64 Debug build for MinnowMax
296 echo bld_vlv.bat /IA32 MNW2 release : IA32 Release build for MinnowMax
297 echo.
298 echo ***************************************************************************
299 set exitCode=1
300 goto Exit
301
302 :BldFail
303 set exitCode=1
304 echo -- Error: EDKII BIOS Build has failed!
305 echo See EDK2.log for more details
306
307 :Exit
308 echo %date% %time%
309 exit /b %exitCode%
310
311 EndLocal