]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/bld_vlv.bat
beec27cb67a95255f417f6747b1b7f8cbd72b537
[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 set WORKSPACE=%CD%
24 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 conf\.cache rmdir /q/s 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 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" == "/c" (
75 echo Removing previous build files ...
76 if exist build (
77 del /f/s/q build > nul
78 rmdir /s/q build
79 )
80 if exist conf\.cache (
81 del /f/s/q conf\.cache > nul
82 rmdir /s/q conf\.cache
83 )
84 echo.
85 shift
86 goto OptLoop
87 )
88
89 if /i "%~1"=="/x64" (
90 set Arch=X64
91 shift
92 goto OptLoop
93 )
94 if /i "%~1"=="/IA32" (
95 set Arch=IA32
96 shift
97 goto OptLoop
98 )
99
100 :: Required argument(s)
101 if "%~1"=="" goto Usage
102
103 ::Remove the values for Platform_Type and Build_Target from BiosIdX.env and stage in Conf\
104 if "%Arch%"=="IA32" (
105 findstr /b /v "BOARD_ID BUILD_TYPE" %PLATFORM_PACKAGE%\BiosIdR.env > Conf\BiosId.env
106 echo DEFINE X64_CONFIG = FALSE >> %auto_config_inc%
107 ) else if "%Arch%"=="X64" (
108 findstr /b /v "BOARD_ID BUILD_TYPE" %PLATFORM_PACKAGE%\BiosIdx64R.env > Conf\BiosId.env
109 echo DEFINE X64_CONFIG = TRUE >> %auto_config_inc%
110 )
111
112 :: -- Build flags settings for each Platform --
113 echo Setting %1 platform configuration and BIOS ID...
114 if /i "%~1" == "MNW2" (
115 echo BOARD_ID = MNW2MAX >> %Conf\BiosId.env
116 echo DEFINE ENBDT_PF_BUILD = TRUE >> %auto_config_inc%
117
118 ) else (
119 echo Error - Unsupported PlatformType: %1
120 goto Usage
121 )
122 set Platform_Type=%~1
123
124 if /i "%~2" == "RELEASE" (
125 set target=RELEASE
126 echo BUILD_TYPE = R >> Conf\BiosId.env
127 ) else (
128 set target=DEBUG
129 echo BUILD_TYPE = D >> Conf\BiosId.env
130 )
131
132 ::**********************************************************************
133 :: Additional EDK Build Setup/Configuration
134 ::**********************************************************************
135 echo.
136 echo Setting the Build environment for VS2008/VS2010/VS2012/VS2013...
137 if defined VS90COMNTOOLS (
138 if not defined VSINSTALLDIR call "%VS90COMNTOOLS%\vsvars32.bat"
139 if /I "%VS90COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\" (
140 set TOOL_CHAIN_TAG=VS2008
141 ) else (
142 set TOOL_CHAIN_TAG=VS2008x86
143 )
144 ) else if defined VS100COMNTOOLS (
145 if not defined VSINSTALLDIR call "%VS100COMNTOOLS%\vsvars32.bat"
146 if /I "%VS100COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\" (
147 set TOOL_CHAIN_TAG=VS2010
148 ) else (
149 set TOOL_CHAIN_TAG=VS2010x86
150 )
151 ) else if defined VS110COMNTOOLS (
152 if not defined VSINSTALLDIR call "%VS110COMNTOOLS%\vsvars32.bat"
153 if /I "%VS110COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 11.0\Common7\Tools\" (
154 set TOOL_CHAIN_TAG=VS2012
155 ) else (
156 set TOOL_CHAIN_TAG=VS2012x86
157 )
158 ) else if defined VS120COMNTOOLS (
159 if not defined VSINSTALLDIR call "%VS120COMNTOOLS%\vsvars32.bat"
160 if /I "%VS120COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\" (
161 set TOOL_CHAIN_TAG=VS2013
162 ) else (
163 set TOOL_CHAIN_TAG=VS2013x86
164 )
165 ) else (
166 echo --ERROR: VS2008/VS2010/VS2012/VS2013 not installed correctly. VS90COMNTOOLS/VS100COMNTOOLS/VS110COMNTOOLS/VS120COMNTOOLS not defined ^^!
167 echo.
168 goto :BldFail
169 )
170
171 echo Ensuring correct build directory is present for GenBiosId...
172 set BUILD_PATH=Build\%PLATFORM_PACKAGE%\%TARGET%_%TOOL_CHAIN_TAG%
173
174 echo Modifing Conf files for this build...
175 :: Remove lines with these tags from target.txt
176 findstr /V "TARGET TARGET_ARCH TOOL_CHAIN_TAG BUILD_RULE_CONF ACTIVE_PLATFORM MAX_CONCURRENT_THREAD_NUMBER" Conf\target.txt > Conf\target.txt.tmp
177
178 echo TARGET = %TARGET% >> Conf\target.txt.tmp
179 if "%Arch%"=="IA32" (
180 echo TARGET_ARCH = IA32 >> Conf\target.txt.tmp
181 ) else if "%Arch%"=="X64" (
182 echo TARGET_ARCH = IA32 X64 >> Conf\target.txt.tmp
183 )
184 echo TOOL_CHAIN_TAG = %TOOL_CHAIN_TAG% >> Conf\target.txt.tmp
185 echo BUILD_RULE_CONF = Conf/build_rule.txt >> Conf\target.txt.tmp
186 if %Source% == 0 (
187 echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE%/PlatformPkg%Arch%.dsc >> Conf\target.txt.tmp
188 ) else (
189 echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE%/PlatformPkg%Arch%Source.dsc >> Conf\target.txt.tmp
190 )
191 echo MAX_CONCURRENT_THREAD_NUMBER = %build_threads% >> Conf\target.txt.tmp
192
193 move /Y Conf\target.txt.tmp Conf\target.txt >nul
194
195 ::**********************************************************************
196 :: Build BIOS
197 ::**********************************************************************
198
199 echo Creating BiosId...
200 pushd %PLATFORM_PACKAGE%
201 if not exist ..\%BUILD_PATH%\IA32 mkdir ..\%BUILD_PATH%\IA32
202 GenBiosId.exe -i ..\Conf\BiosId.env -o ..\%BUILD_PATH%\IA32\BiosId.bin -ob ..\Conf\BiosId.bat
203 if "%Arch%"=="X64" (
204 if not exist ..\%BUILD_PATH%\X64 mkdir ..\%BUILD_PATH%\X64
205 GenBiosId.exe -i ..\Conf\BiosId.env -o ..\%BUILD_PATH%\X64\BiosId.bin -ob ..\Conf\BiosId.bat
206 )
207 popd
208
209
210 if %ERRORLEVEL% NEQ 0 goto BldFail
211
212 echo.
213 echo Invoking EDK2 build...
214 call build %Build_Flags%
215
216 if %ERRORLEVEL% NEQ 0 goto BldFail
217
218 ::**********************************************************************
219 :: Post Build processing and cleanup
220 ::**********************************************************************
221
222 echo Running fce...
223
224 pushd %PLATFORM_PACKAGE%
225 :: Extract Hii data from build and store in HiiDefaultData.txt
226 fce read -i ..\%BUILD_PATH%\FV\Vlv.fd > ..\%BUILD_PATH%\FV\HiiDefaultData.txt
227
228 :: save changes to VlvXXX.fd
229 fce update -i ..\%BUILD_PATH%\FV\Vlv.fd -s ..\%BUILD_PATH%\FV\HiiDefaultData.txt -o ..\%BUILD_PATH%\FV\Vlv%Arch%.fd
230
231 popd
232
233 if %ERRORLEVEL% NEQ 0 goto BldFail
234 ::echo FD successfully updated with default Hii values.
235
236 :: Set the Board_Id, Build_Type, Version_Major, and Version_Minor environment variables
237 find /v "#" Conf\BiosId.env > ver_strings
238 for /f "tokens=1,3" %%i in (ver_strings) do set %%i=%%j
239 del /f/q ver_strings >nul
240
241 set BIOS_Name=%BOARD_ID%_%Arch%_%BUILD_TYPE%_%VERSION_MAJOR%_%VERSION_MINOR%.ROM
242 copy /y/b %BUILD_PATH%\FV\Vlv%Arch%.fd %WORKSPACE%\%BIOS_Name% >nul
243 copy /y/b %BUILD_PATH%\FV\Vlv%Arch%.fd %BUILD_PATH%\FV\Vlv.ROM >nul
244
245 echo.
246 echo Build location: %BUILD_PATH%
247 echo BIOS ROM Created: %BIOS_Name%
248 echo.
249 echo -------------------- The EDKII BIOS build has successfully completed. --------------------
250 echo.
251
252 @REM build capsule here
253 if "%openssl_path%" == "" goto Exit
254 echo > %BUILD_PATH%\FV\SYSTEMFIRMWAREUPDATECARGO.Fv
255 build -p %PLATFORM_PACKAGE%\PlatformCapsule.dsc
256
257 goto Exit
258
259 :Usage
260 echo.
261 echo ***************************************************************************
262 echo Build BIOS rom for VLV platforms.
263 echo.
264 echo Usage: bld_vlv.bat [options] PlatformType [Build Target]
265 echo.
266 echo /c CleanAll before building
267 echo /l Generate build log file
268 echo /y Generate build report file
269 echo /IA32 Set Arch to IA32 (default: X64)
270 echo /X64 Set Arch to X64 (default: X64)
271 echo.
272 echo Platform Types: MNW2
273 echo Build Targets: Debug, Release (default: Debug)
274 echo.
275 echo Examples:
276 echo bld_vlv.bat MNW2 : X64 Debug build for MinnowMax
277 echo bld_vlv.bat /IA32 MNW2 release : IA32 Release build for MinnowMax
278 echo.
279 echo ***************************************************************************
280 set exitCode=1
281 goto Exit
282
283 :BldFail
284 set exitCode=1
285 echo -- Error: EDKII BIOS Build has failed!
286 echo See EDK2.log for more details
287
288 :Exit
289 echo %date% %time%
290 exit /b %exitCode%
291
292 EndLocal