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