Build_IFWI.bat 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. @REM Go to work space directory.
  10. cd ..
  11. cd ..
  12. :: Assign initial values
  13. set exitCode=0
  14. set "Build_Flags= "
  15. set "Stitch_Flags= "
  16. set Arch=X64
  17. set PLATFORM_PACKAGE=Vlv2TbltDevicePkg
  18. set PLATFORM_PATH=%WORKSPACE%
  19. if not exist %PLATFORM_PATH%\%PLATFORM_PACKAGE% (
  20. if defined PACKAGES_PATH (
  21. for %%i IN (%PACKAGES_PATH%) DO (
  22. if exist %%~fi\%PLATFORM_PACKAGE% (
  23. set PLATFORM_PATH=%%~fi
  24. goto PlatformPackageFound
  25. )
  26. )
  27. ) else (
  28. echo.
  29. echo !!! ERROR !!! Cannot find %PLATFORM_PACKAGE% !!!
  30. echo.
  31. goto Exit
  32. )
  33. )
  34. :PlatformPackageFound
  35. :: Parse Optional arguments
  36. :OptLoop
  37. if /i "%~1"=="/?" goto Usage
  38. if /i "%~1"=="/q" (
  39. set Build_Flags=%Build_Flags% /q
  40. shift
  41. goto OptLoop
  42. )
  43. if /i "%~1"=="/l" (
  44. set Build_Flags=%Build_Flags% /l
  45. shift
  46. goto OptLoop
  47. )
  48. if /i "%~1"=="/y" (
  49. set Build_Flags=%Build_Flags% /y
  50. shift
  51. goto OptLoop
  52. )
  53. if /i "%~1"=="/m" (
  54. set Build_Flags=%Build_Flags% /m
  55. shift
  56. goto OptLoop
  57. )
  58. if /i "%~1" == "/c" (
  59. set Build_Flags=%Build_Flags% /c
  60. shift
  61. goto OptLoop
  62. )
  63. if /i "%~1" == "/ECP" (
  64. set Build_Flags=%Build_Flags% /ecp
  65. shift
  66. goto OptLoop
  67. )
  68. if /i "%~1"=="/s" (
  69. set Build_Flags=%Build_Flags% /s
  70. shift
  71. goto OptLoop
  72. )
  73. if /i "%~1"=="/x64" (
  74. set Arch=X64
  75. set Build_Flags=%Build_Flags% /x64
  76. shift
  77. goto OptLoop
  78. )
  79. if /i "%~1"=="/IA32" (
  80. set Arch=IA32
  81. set Build_Flags=%Build_Flags% /IA32
  82. shift
  83. goto OptLoop
  84. )
  85. if /i "%~1"=="/nG" (
  86. set Stitch_Flags=%Stitch_Flags% /nG
  87. shift
  88. goto OptLoop
  89. )
  90. if /i "%~1"=="/nM" (
  91. set Stitch_Flags=%Stitch_Flags% /nM
  92. shift
  93. goto OptLoop
  94. )
  95. if /i "%~1"=="/nB" (
  96. set Stitch_Flags=%Stitch_Flags% /nB
  97. shift
  98. goto OptLoop
  99. )
  100. if /i "%~1"=="/yL" (
  101. set Stitch_Flags=%Stitch_Flags% /yL
  102. shift
  103. goto OptLoop
  104. )
  105. :: Require 2 input parameters
  106. if "%~2"=="" goto Usage
  107. :: Assign required arguments
  108. set Platform_Type=%~1
  109. set Build_Target=%~2
  110. if "%~3"=="" (
  111. set "IFWI_Suffix= "
  112. ) else set "IFWI_Suffix=/S %~3"
  113. :: Build BIOS
  114. echo ======================================================================
  115. echo Build_IFWI: Calling BIOS build Script...
  116. call %PLATFORM_PATH%\%PLATFORM_PACKAGE%\bld_vlv.bat %Build_Flags% %Platform_Type% %Build_Target%
  117. if %ERRORLEVEL% NEQ 0 (
  118. echo echo -- Error Building BIOS & echo.
  119. set exitCode=1
  120. goto exit
  121. )
  122. echo.
  123. echo Finished Building BIOS.
  124. @REM Set BIOS_ID environment variable here.
  125. call %WORKSPACE%\Conf\BiosId.bat
  126. echo BIOS_ID=%BIOS_ID%
  127. :: Set the Board_Id, Build_Type, Version_Major, and Version_Minor environment variables
  128. find /v "#" %WORKSPACE%\Conf\BiosId.env > ver_strings
  129. for /f "tokens=1,3" %%i in (ver_strings) do set %%i=%%j
  130. del /f/q ver_strings >nul
  131. set BIOS_Name=%BOARD_ID%_%Arch%_%BUILD_TYPE%_%VERSION_MAJOR%_%VERSION_MINOR%.ROM
  132. :: Start Integration process
  133. echo ======================================================================
  134. echo Build_IFWI: Calling IFWI Stitching Script...
  135. pushd %PLATFORM_PATH%\%PLATFORM_PACKAGE%\Stitch
  136. :: IFWIStitch.bat [/nG] [/nM] [/nB] [/B BIOS.rom] [/C StitchConfig] [/S IFWISuffix]
  137. call IFWIStitch.bat %Stitch_Flags% /B %BIOS_Name% %IFWI_Suffix%
  138. @echo off
  139. popd
  140. if %ERRORLEVEL% NEQ 0 (
  141. echo echo -- Error Stitching %BIOS_Nam% & echo.
  142. set exitCode=1
  143. )
  144. echo.
  145. echo Build_IFWI is finished.
  146. echo The final IFWI file is located in %ROOT_DIR%\Vlv2TbltDevicePkg\Stitch\
  147. echo ======================================================================
  148. goto Exit
  149. :Usage
  150. echo Script to build BIOS firmware and stitch the entire IFWI.
  151. echo.
  152. echo Usage: Build_IFWI.bat [options] PlatformType BuildTarget [IFWI Suffix]
  153. echo.
  154. echo /c CleanAll before building
  155. echo /x64 Set Arch to X64 (default: X64)
  156. echo /IA32 Set Arch to IA32 (default: X64)
  157. echo /yL Enable SPI lock
  158. echo.
  159. echo Platform Types: MNW2
  160. echo Build Targets: Release, Debug
  161. echo IFWI Suffix: Suffix to append to end of IFWI filename (default: MM_DD_YYYY)
  162. echo.
  163. echo See Stitch/Stitch_Config.txt for additional stitching settings.
  164. echo.
  165. echo If capsule update is needed, please update CAPSULE_ENABLE = TRUE in Config.dsc.
  166. echo If recovery is needed, please update RECOVERY_ENABLE = TRUE in Config.dsc.
  167. echo If either of above is TRUE, please set OPENSSL_PATH in windows evironment
  168. echo and put openssl.exe there, to generate final capsule image.
  169. echo.
  170. set exitCode=1
  171. :Exit
  172. @REM CD to platform package.
  173. cd %PLATFORM_PATH%
  174. exit /b %exitCode%
  175. EndLocal