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