bld_vlv.bat 11 KB

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