]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/bld_vlv.bat
b9c86e356952b7962e6f853ac980348453b35844
[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...
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 (
146 echo --ERROR: VS2008/VS2010 not installed correctly. VS90COMNTOOLS/VS100COMNTOOLS not defined ^^!
147 echo.
148 goto :BldFail
149 )
150
151 echo Ensuring correct build directory is present for GenBiosId...
152 set BUILD_PATH=Build\%PLATFORM_PACKAGE%\%TARGET%_%TOOL_CHAIN_TAG%
153
154 echo Modifing Conf files for this build...
155 :: Remove lines with these tags from target.txt
156 findstr /V "TARGET TARGET_ARCH TOOL_CHAIN_TAG BUILD_RULE_CONF ACTIVE_PLATFORM MAX_CONCURRENT_THREAD_NUMBER" Conf\target.txt > Conf\target.txt.tmp
157
158 echo TARGET = %TARGET% >> Conf\target.txt.tmp
159 if "%Arch%"=="IA32" (
160 echo TARGET_ARCH = IA32 >> Conf\target.txt.tmp
161 ) else if "%Arch%"=="X64" (
162 echo TARGET_ARCH = IA32 X64 >> Conf\target.txt.tmp
163 )
164 echo TOOL_CHAIN_TAG = %TOOL_CHAIN_TAG% >> Conf\target.txt.tmp
165 echo BUILD_RULE_CONF = Conf/build_rule.txt >> Conf\target.txt.tmp
166 if %Source% == 0 (
167 echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE%/PlatformPkg%Arch%.dsc >> Conf\target.txt.tmp
168 ) else (
169 echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE%/PlatformPkg%Arch%Source.dsc >> Conf\target.txt.tmp
170 )
171 echo MAX_CONCURRENT_THREAD_NUMBER = %build_threads% >> Conf\target.txt.tmp
172
173 move /Y Conf\target.txt.tmp Conf\target.txt >nul
174
175 ::**********************************************************************
176 :: Build BIOS
177 ::**********************************************************************
178
179 echo Creating BiosId...
180 pushd %PLATFORM_PACKAGE%
181 if not exist ..\%BUILD_PATH%\IA32 mkdir ..\%BUILD_PATH%\IA32
182 GenBiosId.exe -i ..\Conf\BiosId.env -o ..\%BUILD_PATH%\IA32\BiosId.bin -ob ..\Conf\BiosId.bat
183 if "%Arch%"=="X64" (
184 if not exist ..\%BUILD_PATH%\X64 mkdir ..\%BUILD_PATH%\X64
185 GenBiosId.exe -i ..\Conf\BiosId.env -o ..\%BUILD_PATH%\X64\BiosId.bin -ob ..\Conf\BiosId.bat
186 )
187 popd
188
189
190 if %ERRORLEVEL% NEQ 0 goto BldFail
191
192 echo.
193 echo Invoking EDK2 build...
194 build %Build_Flags%
195
196 if %ERRORLEVEL% NEQ 0 goto BldFail
197
198 ::**********************************************************************
199 :: Post Build processing and cleanup
200 ::**********************************************************************
201
202 echo Running fce...
203
204 pushd %PLATFORM_PACKAGE%
205 :: Extract Hii data from build and store in HiiDefaultData.txt
206 fce read -i ..\%BUILD_PATH%\FV\Vlv.fd > ..\%BUILD_PATH%\FV\HiiDefaultData.txt 1>>EDK2.log 2>&1
207
208 :: copy the Setup variable to the SetupDefault variable and save changes to VlvXXX.fd
209 fce mirror -i ..\%BUILD_PATH%\FV\Vlv.fd -o ..\%BUILD_PATH%\FV\Vlv%Arch%.fd Setup SetupDefault 1>>EDK2.log 2>&1
210
211 popd
212
213 if %ERRORLEVEL% NEQ 0 goto BldFail
214 ::echo FD successfully updated with default Hii values.
215
216 :: Set the Board_Id, Build_Type, Version_Major, and Version_Minor environment variables
217 find /v "#" Conf\BiosId.env > ver_strings
218 for /f "tokens=1,3" %%i in (ver_strings) do set %%i=%%j
219 del /f/q ver_strings >nul
220
221 set BIOS_Name=%BOARD_ID%_%Arch%_%BUILD_TYPE%_%VERSION_MAJOR%_%VERSION_MINOR%.ROM
222 copy /y/b %BUILD_PATH%\FV\Vlv%Arch%.fd %WORKSPACE%\%BIOS_Name% >nul
223
224 echo.
225 echo Build location: %BUILD_PATH%
226 echo BIOS ROM Created: %BIOS_Name%
227 echo.
228 echo -------------------- The EDKII BIOS build has successfully completed. --------------------
229 echo.
230 goto Exit
231
232 :Usage
233 echo.
234 echo ***************************************************************************
235 echo Build BIOS rom for VLV platforms.
236 echo.
237 echo Usage: bld_vlv.bat [options] PlatformType [Build Target]
238 echo.
239 echo /c CleanAll before building
240 echo /IA32 Set Arch to IA32 (default: X64)
241 echo /X64 Set Arch to X64 (default: X64)
242 echo.
243 echo Platform Types: MNW2
244 echo Build Targets: Debug, Release (default: Debug)
245 echo.
246 echo Examples:
247 echo bld_vlv.bat MNW2 : X64 Debug build for MinnowMax
248 echo bld_vlv.bat /IA32 MNW2 release : IA32 Release build for MinnowMax
249 echo.
250 echo ***************************************************************************
251 set exitCode=1
252 goto Exit
253
254 :BldFail
255 set exitCode=1
256 echo -- Error: EDKII BIOS Build has failed!
257 echo See EDK2.log for more details
258
259 :Exit
260 echo %date% %time%
261 exit /b %exitCode%
262
263 EndLocal