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