blob: fc97f425342598e90e0f79dc80a0829b98ff7262 [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301@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
15setlocal EnableDelayedExpansion EnableExtensions
16echo.
17echo %date% %time%
18echo.
19
20::**********************************************************************
21:: Initial Setup
22::**********************************************************************
23set WORKSPACE=%CD%
24if %WORKSPACE:~-1%==\ set WORKSPACE=%WORKSPACE:~0,-1%
25set /a build_threads=1
26set "Build_Flags= "
27set exitCode=0
28set Arch=X64
29set Source=0
30
31:: Clean up previous build files.
32if exist %WORKSPACE%\edk2.log del %WORKSPACE%\edk2.log
33if exist %WORKSPACE%\unitool.log del %WORKSPACE%\unitool.log
34if exist %WORKSPACE%\Conf\target.txt del %WORKSPACE%\Conf\target.txt
35if exist %WORKSPACE%\Conf\tools_def.txt del %WORKSPACE%\Conf\tools_def.txt
36if exist %WORKSPACE%\Conf\build_rule.txt del %WORKSPACE%\Conf\build_rule.txt
37if exist %WORKSPACE%\Conf\FrameworkDatabase.db del %WORKSPACE%\Conf\FrameworkDatabase.db
38if 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
42call edksetup.bat > nul
43@echo off
44
45:: Define platform specific environment variables.
46set PLATFORM_PACKAGE=Vlv2TbltDevicePkg
47set config_file=.\%PLATFORM_PACKAGE%\PlatformPkgConfig.dsc
48set auto_config_inc=.\%PLATFORM_PACKAGE%\AutoPlatformCFG.txt
49
50set EDK_SOURCE=%WORKSPACE%\EdkCompatibilityPkg
51
52::create new AutoPlatformCFG.txt file
53copy /y nul %auto_config_inc% >nul
54
55::**********************************************************************
56:: Parse command line arguments
57::**********************************************************************
58
59:: Optional arguments
60:OptLoop
61if /i "%~1"=="/?" goto Usage
62
63if /i "%~1"=="/l" (
64 set Build_Flags=%Build_Flags% -j EDK2.log
65 shift
66 goto OptLoop
67)
68if /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
83if /i "%~1"=="/x64" (
84 set Arch=X64
85 shift
86 goto OptLoop
87)
88if /i "%~1"=="/IA32" (
89 set Arch=IA32
90 shift
91 goto OptLoop
92)
93
94:: Required argument(s)
95if "%~1"=="" goto Usage
96
97::Remove the values for Platform_Type and Build_Target from BiosIdX.env and stage in Conf\
98if "%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 --
107echo Setting %1 platform configuration and BIOS ID...
108if /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)
116set Platform_Type=%~1
117
118if /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::**********************************************************************
129echo.
130echo Setting the Build environment for VS2008/VS2010/VS2012/VS2013...
131if 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
165echo Ensuring correct build directory is present for GenBiosId...
166set BUILD_PATH=Build\%PLATFORM_PACKAGE%\%TARGET%_%TOOL_CHAIN_TAG%
167
168echo Modifing Conf files for this build...
169:: Remove lines with these tags from target.txt
170findstr /V "TARGET TARGET_ARCH TOOL_CHAIN_TAG BUILD_RULE_CONF ACTIVE_PLATFORM MAX_CONCURRENT_THREAD_NUMBER" Conf\target.txt > Conf\target.txt.tmp
171
172echo TARGET = %TARGET% >> Conf\target.txt.tmp
173if "%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)
178echo TOOL_CHAIN_TAG = %TOOL_CHAIN_TAG% >> Conf\target.txt.tmp
179echo BUILD_RULE_CONF = Conf/build_rule.txt >> Conf\target.txt.tmp
180if %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)
185echo MAX_CONCURRENT_THREAD_NUMBER = %build_threads% >> Conf\target.txt.tmp
186
187move /Y Conf\target.txt.tmp Conf\target.txt >nul
188
189::**********************************************************************
190:: Build BIOS
191::**********************************************************************
192
193echo Creating BiosId...
194pushd %PLATFORM_PACKAGE%
195if 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
197if "%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)
201popd
202
203
204if %ERRORLEVEL% NEQ 0 goto BldFail
205
206echo.
207echo Invoking EDK2 build...
208build %Build_Flags%
209
210if %ERRORLEVEL% NEQ 0 goto BldFail
211
212::**********************************************************************
213:: Post Build processing and cleanup
214::**********************************************************************
215
216echo Running fce...
217
218pushd %PLATFORM_PACKAGE%
219:: Extract Hii data from build and store in HiiDefaultData.txt
220fce read -i ..\%BUILD_PATH%\FV\Vlv.fd > ..\%BUILD_PATH%\FV\HiiDefaultData.txt 1>>EDK2.log 2>&1
221
222:: copy the Setup variable to the SetupDefault variable and save changes to VlvXXX.fd
223fce mirror -i ..\%BUILD_PATH%\FV\Vlv.fd -o ..\%BUILD_PATH%\FV\Vlv%Arch%.fd Setup SetupDefault 1>>EDK2.log 2>&1
224
225popd
226
227if %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
231find /v "#" Conf\BiosId.env > ver_strings
232for /f "tokens=1,3" %%i in (ver_strings) do set %%i=%%j
233del /f/q ver_strings >nul
234
235set BIOS_Name=%BOARD_ID%_%Arch%_%BUILD_TYPE%_%VERSION_MAJOR%_%VERSION_MINOR%.ROM
236copy /y/b %BUILD_PATH%\FV\Vlv%Arch%.fd %WORKSPACE%\%BIOS_Name% >nul
237
238echo.
239echo Build location: %BUILD_PATH%
240echo BIOS ROM Created: %BIOS_Name%
241echo.
242echo -------------------- The EDKII BIOS build has successfully completed. --------------------
243echo.
244goto Exit
245
246:Usage
247echo.
248echo ***************************************************************************
249echo Build BIOS rom for VLV platforms.
250echo.
251echo Usage: bld_vlv.bat [options] PlatformType [Build Target]
252echo.
253echo /c CleanAll before building
254echo /IA32 Set Arch to IA32 (default: X64)
255echo /X64 Set Arch to X64 (default: X64)
256echo.
257echo Platform Types: MNW2
258echo Build Targets: Debug, Release (default: Debug)
259echo.
260echo Examples:
261echo bld_vlv.bat MNW2 : X64 Debug build for MinnowMax
262echo bld_vlv.bat /IA32 MNW2 release : IA32 Release build for MinnowMax
263echo.
264echo ***************************************************************************
265set exitCode=1
266goto Exit
267
268:BldFail
269set exitCode=1
270echo -- Error: EDKII BIOS Build has failed!
271echo See EDK2.log for more details
272
273:Exit
274echo %date% %time%
275exit /b %exitCode%
276
277EndLocal