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