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