Vlv2TbltDevicePkg: Add /m flag for multi-processor build
[mirror_edk2.git] / Vlv2TbltDevicePkg / bld_vlv.bat
CommitLineData
3cbfba02
DW
1@REM @file\r
2@REM Windows batch file to build BIOS ROM\r
3@REM\r
12057760 4@REM Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
3cbfba02
DW
5@REM This program and the accompanying materials\r
6@REM are licensed and made available under the terms and conditions of the BSD License\r
7@REM which accompanies this distribution. The full text of the license may be found at\r
8@REM http://opensource.org/licenses/bsd-license.php\r
9@REM\r
10@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12@REM\r
13\r
14@echo off\r
15setlocal EnableDelayedExpansion EnableExtensions\r
16echo.\r
17echo %date% %time%\r
18echo.\r
19\r
20::**********************************************************************\r
21:: Initial Setup\r
22::**********************************************************************\r
23set WORKSPACE=%CD%\r
24if %WORKSPACE:~-1%==\ set WORKSPACE=%WORKSPACE:~0,-1%\r
25set /a build_threads=1\r
26set "Build_Flags= "\r
27set exitCode=0\r
28set Arch=X64\r
29set Source=0\r
30\r
31:: Clean up previous build files.\r
eafde7a2
MK
32if exist %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.log del %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.log\r
33if exist %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.report del %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.report\r
3cbfba02
DW
34if exist %WORKSPACE%\unitool.log del %WORKSPACE%\unitool.log\r
35if exist %WORKSPACE%\Conf\target.txt del %WORKSPACE%\Conf\target.txt\r
36if exist %WORKSPACE%\Conf\tools_def.txt del %WORKSPACE%\Conf\tools_def.txt\r
37if exist %WORKSPACE%\Conf\build_rule.txt del %WORKSPACE%\Conf\build_rule.txt\r
38if exist %WORKSPACE%\Conf\FrameworkDatabase.db del %WORKSPACE%\Conf\FrameworkDatabase.db\r
39if exist conf\.cache rmdir /q/s conf\.cache\r
40\r
41:: Setup EDK environment. Edksetup puts new copies of target.txt, tools_def.txt, build_rule.txt in WorkSpace\Conf\r
42:: Also run edksetup as soon as possible to avoid it from changing environment variables we're overriding\r
43call edksetup.bat > nul\r
44@echo off\r
45\r
46:: Define platform specific environment variables.\r
47set PLATFORM_PACKAGE=Vlv2TbltDevicePkg\r
48set config_file=.\%PLATFORM_PACKAGE%\PlatformPkgConfig.dsc\r
49set auto_config_inc=.\%PLATFORM_PACKAGE%\AutoPlatformCFG.txt\r
50\r
51set EDK_SOURCE=%WORKSPACE%\EdkCompatibilityPkg\r
52\r
53::create new AutoPlatformCFG.txt file\r
54copy /y nul %auto_config_inc% >nul\r
55\r
56::**********************************************************************\r
57:: Parse command line arguments\r
58::**********************************************************************\r
59\r
60:: Optional arguments\r
61:OptLoop\r
62if /i "%~1"=="/?" goto Usage\r
63\r
64if /i "%~1"=="/l" (\r
eafde7a2
MK
65 set Build_Flags=%Build_Flags% -j %PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.log\r
66 shift\r
67 goto OptLoop\r
68)\r
69if /i "%~1"=="/y" (\r
70 set Build_Flags=%Build_Flags% -y %PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.report\r
3cbfba02
DW
71 shift\r
72 goto OptLoop\r
73)\r
eae631bc
MK
74if /i "%~1"=="/m" (\r
75 if defined NUMBER_OF_PROCESSORS (\r
76 set /a build_threads=%NUMBER_OF_PROCESSORS%+1\r
77 )\r
78 shift\r
79 goto OptLoop\r
80)\r
3cbfba02
DW
81if /i "%~1" == "/c" (\r
82 echo Removing previous build files ...\r
83 if exist build (\r
e2c32486 84 del /f/s/q build > nul\r
3cbfba02
DW
85 rmdir /s/q build\r
86 )\r
87 if exist conf\.cache (\r
e2c32486 88 del /f/s/q conf\.cache > nul\r
3cbfba02
DW
89 rmdir /s/q conf\.cache\r
90 )\r
91 echo.\r
92 shift\r
93 goto OptLoop\r
94)\r
95\r
96if /i "%~1"=="/x64" (\r
97 set Arch=X64\r
98 shift\r
99 goto OptLoop\r
100)\r
101if /i "%~1"=="/IA32" (\r
102 set Arch=IA32\r
103 shift\r
104 goto OptLoop\r
105)\r
106\r
107:: Required argument(s)\r
108if "%~1"=="" goto Usage\r
109\r
110::Remove the values for Platform_Type and Build_Target from BiosIdX.env and stage in Conf\\r
111if "%Arch%"=="IA32" (\r
112 findstr /b /v "BOARD_ID BUILD_TYPE" %PLATFORM_PACKAGE%\BiosIdR.env > Conf\BiosId.env\r
113 echo DEFINE X64_CONFIG = FALSE >> %auto_config_inc%\r
114) else if "%Arch%"=="X64" (\r
115 findstr /b /v "BOARD_ID BUILD_TYPE" %PLATFORM_PACKAGE%\BiosIdx64R.env > Conf\BiosId.env\r
116 echo DEFINE X64_CONFIG = TRUE >> %auto_config_inc%\r
117)\r
118\r
119:: -- Build flags settings for each Platform --\r
120echo Setting %1 platform configuration and BIOS ID...\r
121if /i "%~1" == "MNW2" (\r
122 echo BOARD_ID = MNW2MAX >> %Conf\BiosId.env\r
123 echo DEFINE ENBDT_PF_BUILD = TRUE >> %auto_config_inc%\r
124 \r
125) else (\r
126 echo Error - Unsupported PlatformType: %1\r
127 goto Usage\r
128)\r
129set Platform_Type=%~1\r
130\r
131if /i "%~2" == "RELEASE" (\r
132 set target=RELEASE\r
133 echo BUILD_TYPE = R >> Conf\BiosId.env\r
134) else (\r
135 set target=DEBUG\r
136 echo BUILD_TYPE = D >> Conf\BiosId.env\r
137)\r
138\r
139::**********************************************************************\r
6e4c9170
BC
140:: Additional EDK Build Setup/Configuration
141::**********************************************************************
142echo.
143echo Setting the Build environment for VS2008/VS2010/VS2012/VS2013...\r
144if defined VS90COMNTOOLS (
145 if not defined VSINSTALLDIR call "%VS90COMNTOOLS%\vsvars32.bat"
146 if /I "%VS90COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\" (
3cbfba02
DW
147 set TOOL_CHAIN_TAG=VS2008\r
148 ) else (\r
149 set TOOL_CHAIN_TAG=VS2008x86\r
150 )\r
151 ) else if defined VS100COMNTOOLS (\r
152 if not defined VSINSTALLDIR call "%VS100COMNTOOLS%\vsvars32.bat"\r
153 if /I "%VS100COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\" (\r
154 set TOOL_CHAIN_TAG=VS2010\r
6e4c9170
BC
155 ) else (\r
156 set TOOL_CHAIN_TAG=VS2010x86
157 )\r
158) else if defined VS110COMNTOOLS (\r
159 if not defined VSINSTALLDIR call "%VS110COMNTOOLS%\vsvars32.bat"\r
160 if /I "%VS110COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 11.0\Common7\Tools\" (\r
161 set TOOL_CHAIN_TAG=VS2012\r
162 ) else (\r
163 set TOOL_CHAIN_TAG=VS2012x86\r
164 )\r
165) else if defined VS120COMNTOOLS (\r
166 if not defined VSINSTALLDIR call "%VS120COMNTOOLS%\vsvars32.bat"\r
167 if /I "%VS120COMNTOOLS%" == "C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\" (\r
168 set TOOL_CHAIN_TAG=VS2013\r
169 ) else (\r
170 set TOOL_CHAIN_TAG=VS2013x86\r
171 )\r
172) else (
173 echo --ERROR: VS2008/VS2010/VS2012/VS2013 not installed correctly. VS90COMNTOOLS/VS100COMNTOOLS/VS110COMNTOOLS/VS120COMNTOOLS not defined ^^!\r
174 echo.\r
175 goto :BldFail\r
176)
3cbfba02
DW
177\r
178echo Ensuring correct build directory is present for GenBiosId...\r
179set BUILD_PATH=Build\%PLATFORM_PACKAGE%\%TARGET%_%TOOL_CHAIN_TAG%\r
180\r
181echo Modifing Conf files for this build...\r
182:: Remove lines with these tags from target.txt\r
183findstr /V "TARGET TARGET_ARCH TOOL_CHAIN_TAG BUILD_RULE_CONF ACTIVE_PLATFORM MAX_CONCURRENT_THREAD_NUMBER" Conf\target.txt > Conf\target.txt.tmp\r
184\r
185echo TARGET = %TARGET% >> Conf\target.txt.tmp\r
186if "%Arch%"=="IA32" (\r
187 echo TARGET_ARCH = IA32 >> Conf\target.txt.tmp\r
188) else if "%Arch%"=="X64" (\r
189 echo TARGET_ARCH = IA32 X64 >> Conf\target.txt.tmp\r
190)\r
191echo TOOL_CHAIN_TAG = %TOOL_CHAIN_TAG% >> Conf\target.txt.tmp\r
192echo BUILD_RULE_CONF = Conf/build_rule.txt >> Conf\target.txt.tmp\r
193if %Source% == 0 (\r
194 echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE%/PlatformPkg%Arch%.dsc >> Conf\target.txt.tmp\r
195) else (\r
196 echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE%/PlatformPkg%Arch%Source.dsc >> Conf\target.txt.tmp\r
197)\r
198echo MAX_CONCURRENT_THREAD_NUMBER = %build_threads% >> Conf\target.txt.tmp\r
199\r
200move /Y Conf\target.txt.tmp Conf\target.txt >nul\r
201\r
202::**********************************************************************\r
203:: Build BIOS\r
204::**********************************************************************\r
205\r
206echo Creating BiosId...\r
207pushd %PLATFORM_PACKAGE%\r
208if not exist ..\%BUILD_PATH%\IA32 mkdir ..\%BUILD_PATH%\IA32\r
209 GenBiosId.exe -i ..\Conf\BiosId.env -o ..\%BUILD_PATH%\IA32\BiosId.bin -ob ..\Conf\BiosId.bat\r
210if "%Arch%"=="X64" (\r
211 if not exist ..\%BUILD_PATH%\X64 mkdir ..\%BUILD_PATH%\X64\r
212 GenBiosId.exe -i ..\Conf\BiosId.env -o ..\%BUILD_PATH%\X64\BiosId.bin -ob ..\Conf\BiosId.bat\r
213)\r
214popd\r
215\r
216\r
217if %ERRORLEVEL% NEQ 0 goto BldFail\r
218\r
219echo.\r
220echo Invoking EDK2 build...\r
6f514143 221call build %Build_Flags%\r
3cbfba02
DW
222\r
223if %ERRORLEVEL% NEQ 0 goto BldFail\r
224\r
225::**********************************************************************\r
226:: Post Build processing and cleanup\r
227::**********************************************************************\r
228\r
229echo Running fce...\r
230\r
231pushd %PLATFORM_PACKAGE%\r
232:: Extract Hii data from build and store in HiiDefaultData.txt\r
620f2891 233fce read -i ..\%BUILD_PATH%\FV\Vlv.fd > ..\%BUILD_PATH%\FV\HiiDefaultData.txt\r
3cbfba02 234\r
620f2891
TH
235:: save changes to VlvXXX.fd\r
236fce update -i ..\%BUILD_PATH%\FV\Vlv.fd -s ..\%BUILD_PATH%\FV\HiiDefaultData.txt -o ..\%BUILD_PATH%\FV\Vlv%Arch%.fd\r
3cbfba02
DW
237\r
238popd\r
239\r
240if %ERRORLEVEL% NEQ 0 goto BldFail\r
241::echo FD successfully updated with default Hii values.\r
242\r
243:: Set the Board_Id, Build_Type, Version_Major, and Version_Minor environment variables\r
244find /v "#" Conf\BiosId.env > ver_strings\r
245for /f "tokens=1,3" %%i in (ver_strings) do set %%i=%%j\r
246del /f/q ver_strings >nul\r
247\r
248set BIOS_Name=%BOARD_ID%_%Arch%_%BUILD_TYPE%_%VERSION_MAJOR%_%VERSION_MINOR%.ROM\r
249copy /y/b %BUILD_PATH%\FV\Vlv%Arch%.fd %WORKSPACE%\%BIOS_Name% >nul\r
12057760 250copy /y/b %BUILD_PATH%\FV\Vlv%Arch%.fd %BUILD_PATH%\FV\Vlv.ROM >nul\r
3cbfba02
DW
251\r
252echo.\r
253echo Build location: %BUILD_PATH%\r
254echo BIOS ROM Created: %BIOS_Name%\r
255echo.\r
256echo -------------------- The EDKII BIOS build has successfully completed. --------------------\r
257echo.\r
12057760
JY
258\r
259@REM build capsule here\r
260if "%openssl_path%" == "" goto Exit\r
261echo > %BUILD_PATH%\FV\SYSTEMFIRMWAREUPDATECARGO.Fv\r
262build -p %PLATFORM_PACKAGE%\PlatformCapsule.dsc\r
263\r
3cbfba02
DW
264goto Exit\r
265\r
266:Usage\r
267echo.\r
268echo ***************************************************************************\r
269echo Build BIOS rom for VLV platforms.\r
270echo.\r
271echo Usage: bld_vlv.bat [options] PlatformType [Build Target]\r
272echo.\r
273echo /c CleanAll before building\r
eafde7a2
MK
274echo /l Generate build log file\r
275echo /y Generate build report file\r
eae631bc 276echo /m Enable multi-processor build\r
3cbfba02
DW
277echo /IA32 Set Arch to IA32 (default: X64)\r
278echo /X64 Set Arch to X64 (default: X64)\r
279echo.\r
280echo Platform Types: MNW2\r
281echo Build Targets: Debug, Release (default: Debug)\r
282echo.\r
283echo Examples:\r
284echo bld_vlv.bat MNW2 : X64 Debug build for MinnowMax\r
285echo bld_vlv.bat /IA32 MNW2 release : IA32 Release build for MinnowMax\r
286echo.\r
287echo ***************************************************************************\r
288set exitCode=1\r
289goto Exit\r
290\r
291:BldFail\r
292set exitCode=1\r
293echo -- Error: EDKII BIOS Build has failed!\r
294echo See EDK2.log for more details\r
295\r
296:Exit\r
297echo %date% %time%\r
298exit /b %exitCode%\r
299\r
300EndLocal\r