bld_vlv.bat 9.9 KB

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