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