2015-01-12 10:37:20 +01:00
@ REM @file
@ REM Windows batch file to build BIOS ROM
@ REM
2019-02-28 04:12:42 +01:00
@ REM Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
2019-04-04 01:07:37 +02:00
@ REM SPDX-License-Identifier: BSD-2-Clause-Patent
2015-01-12 10:37:20 +01:00
@ REM
@ echo off
setlocal EnableDelayedExpansion EnableExtensions
echo .
echo %date% %time%
echo .
2019-02-28 04:12:42 +01:00
2015-01-12 10:37:20 +01:00
: :**********************************************************************
: : Initial Setup
: :**********************************************************************
2019-02-28 04:12:42 +01:00
set WORKSPACE = %CD%
if %WORKSPACE:~-1% == \ set WORKSPACE = %WORKSPACE:~0,-1%
2015-01-12 10:37:20 +01:00
set /a build_threads = 1
set " Build_Flags= "
set exitCode = 0
set Arch = X64
set Source = 0
2019-02-28 04:12:42 +01:00
set CORE_PATH = %WORKSPACE% \edk2
set PLATFORM_PATH = %WORKSPACE% \edk2
cd ./edk2
2015-01-12 10:37:20 +01:00
: : Clean up previous build files.
2019-02-28 04:12:42 +01:00
if exist %CORE_PATH% \edk2.log del %CORE_PATH% \edk2.log
if exist %CORE_PATH% \unitool.log del %CORE_PATH% \unitool.log
if exist %CORE_PATH% \Conf\target.txt del %CORE_PATH% \Conf\target.txt
if exist %CORE_PATH% \Conf\tools_def.txt del %CORE_PATH% \Conf\tools_def.txt
if exist %CORE_PATH% \Conf\build_rule.txt del %CORE_PATH% \Conf\build_rule.txt
if exist %CORE_PATH% \Conf\FrameworkDatabase.db del %CORE_PATH% \Conf\FrameworkDatabase.db
if exist conf\.cache rmdir /q/s conf\.cache
2015-01-12 10:37:20 +01:00
: : Setup EDK environment. Edksetup puts new copies of target.txt, tools_def.txt, build_rule.txt in WorkSpace\Conf
: : Also run edksetup as soon as possible to avoid it from changing environment variables we're overriding
2019-02-28 04:12:42 +01:00
call %CORE_PATH% \edksetup.bat Rebuild
2015-01-12 10:37:20 +01:00
@ echo off
: : Define platform specific environment variables.
2019-02-28 04:12:42 +01:00
set PLATFORM_NAME = Vlv2TbltDevicePkg
set PLATFORM_PACKAGE = %PLATFORM_PATH% \Vlv2TbltDevicePkg
set config_file = %PLATFORM_PACKAGE% \PlatformPkgConfig.dsc
set auto_config_inc = %PLATFORM_PACKAGE% \AutoPlatformCFG.txt
2015-01-12 10:37:20 +01:00
: :create new AutoPlatformCFG.txt file
copy /y nul %auto_config_inc% > nul
: :**********************************************************************
: : Parse command line arguments
: :**********************************************************************
: : Optional arguments
: OptLoop
if /i " %~1 " == " /? " goto Usage
if /i " %~1 " == " /l " (
2019-02-28 04:12:42 +01:00
set Build_Flags = %Build_Flags% -j EDK2.log
2016-11-29 20:28:07 +01:00
shift
goto OptLoop
)
if /i " %~1 " == " /y " (
set Build_Flags = %Build_Flags% -y %PLATFORM_PACKAGE% \EDK2_%PLATFORM_PACKAGE% .report
2015-01-12 10:37:20 +01:00
shift
goto OptLoop
)
2016-11-29 21:01:44 +01:00
if /i " %~1 " == " /m " (
if defined NUMBER_OF_PROCESSORS (
set /a build_threads =% NUMBER_OF_PROCESSORS %+ 1
)
shift
goto OptLoop
)
2015-01-12 10:37:20 +01:00
if /i " %~1 " == " /c " (
echo Removing previous build files ...
if exist build (
2016-11-29 20:19:20 +01:00
del /f/s/q build > nul
2015-01-12 10:37:20 +01:00
rmdir /s/q build
)
if exist conf\.cache (
2016-11-29 20:19:20 +01:00
del /f/s/q conf\.cache > nul
2015-01-12 10:37:20 +01:00
rmdir /s/q conf\.cache
)
echo .
shift
goto OptLoop
)
if /i " %~1 " == " /x64 " (
set Arch = X64
shift
goto OptLoop
)
if /i " %~1 " == " /IA32 " (
set Arch = IA32
shift
goto OptLoop
)
: : Required argument(s)
if " %~1 " == " " goto Usage
: :Remove the values for Platform_Type and Build_Target from BiosIdX.env and stage in Conf\
if " %Arch% " == " IA32 " (
2019-02-28 04:12:42 +01:00
findstr /b /v " BOARD_ID BUILD_TYPE " %PLATFORM_PACKAGE% \BiosIdR.env > Conf\BiosId.env
2015-01-12 10:37:20 +01:00
echo DEFINE X64_CONFIG = FALSE >> %auto_config_inc%
) else if "%Arch%"=="X64" (
2019-02-28 04:12:42 +01:00
findstr /b /v " BOARD_ID BUILD_TYPE " %PLATFORM_PACKAGE% \BiosIdx64R.env > Conf\BiosId.env
2015-01-12 10:37:20 +01:00
echo DEFINE X64_CONFIG = TRUE >> %auto_config_inc%
)
: : -- Build flags settings for each Platform --
echo Setting %1 platform configuration and BIOS ID...
if /i " %~1 " == " MNW2 " (
2019-02-28 04:17:03 +01:00
echo BOARD_ID = MNW2MAX >> Conf\BiosId.env
2015-01-12 10:37:20 +01:00
echo DEFINE ENBDT_PF_BUILD = TRUE >> %auto_config_inc%
) else (
echo Error - Unsupported PlatformType: %1
goto Usage
)
set Platform_Type = %~1
if /i " %~2 " == " RELEASE " (
set target = RELEASE
2019-02-28 04:12:42 +01:00
echo BUILD_TYPE = R >> Conf\BiosId.env
2015-01-12 10:37:20 +01:00
) else (
set target = DEBUG
2019-02-28 04:12:42 +01:00
echo BUILD_TYPE = D >> Conf\BiosId.env
2015-01-12 10:37:20 +01:00
)
: :**********************************************************************
2017-12-29 00:17:31 +01:00
: : Additional EDK Build Setup/Configuration
: :**********************************************************************
echo .
2019-02-28 04:12:42 +01:00
echo Setting the Build environment for VS2015/VS2013/VS2012/VS2010/VS2008...
2017-12-29 00:17:31 +01:00
if defined VS140COMNTOOLS (
if not defined VSINSTALLDIR call " %VS140COMNTOOLS% \vsvars32.bat "
if /I " %VS140COMNTOOLS% " == " C:\Program Files\Microsoft Visual Studio 14.0\Common7\Tools\ " (
set TOOL_CHAIN_TAG = VS2015
2015-01-26 07:50:22 +01:00
) else (
2017-12-29 00:17:31 +01:00
set TOOL_CHAIN_TAG = VS2015x86
2019-02-28 04:12:42 +01:00
)
2017-12-29 00:17:31 +01:00
) else if defined VS120COMNTOOLS (
if not defined VSINSTALLDIR call " %VS120COMNTOOLS% \vsvars32.bat "
if /I " %VS120COMNTOOLS% " == " C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\ " (
set TOOL_CHAIN_TAG = VS2013
) else (
set TOOL_CHAIN_TAG = VS2013x86
2015-01-26 07:50:22 +01:00
)
) else if defined VS110COMNTOOLS (
if not defined VSINSTALLDIR call " %VS110COMNTOOLS% \vsvars32.bat "
if /I " %VS110COMNTOOLS% " == " C:\Program Files\Microsoft Visual Studio 11.0\Common7\Tools\ " (
set TOOL_CHAIN_TAG = VS2012
) else (
set TOOL_CHAIN_TAG = VS2012x86
)
2017-12-29 00:17:31 +01:00
) else if defined VS100COMNTOOLS (
if not defined VSINSTALLDIR call " %VS100COMNTOOLS% \vsvars32.bat "
if /I " %VS100COMNTOOLS% " == " C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\ " (
set TOOL_CHAIN_TAG = VS2010
2015-01-26 07:50:22 +01:00
) else (
2017-12-29 00:17:31 +01:00
set TOOL_CHAIN_TAG = VS2010x86
)
) else if defined VS90COMNTOOLS (
if not defined VSINSTALLDIR call " %VS90COMNTOOLS% \vsvars32.bat "
if /I " %VS90COMNTOOLS% " == " C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\ " (
set TOOL_CHAIN_TAG = VS2008
) else (
set TOOL_CHAIN_TAG = VS2008x86
2015-01-26 07:50:22 +01:00
)
2017-12-29 00:17:31 +01:00
) else (
2019-02-28 04:12:42 +01:00
echo --ERROR: VS2015/VS2013/VS2012/VS2010/VS2008 not installed correctly. VS140COMNTOOLS/VS120COMNTOOLS/VS110COMNTOOLS/VS100COMNTOOLS/VS90COMNTOOLS not defined ^^!
2015-01-26 07:50:22 +01:00
echo .
goto : BldFail
2017-12-29 00:17:31 +01:00
)
2015-01-12 10:37:20 +01:00
echo Ensuring correct build directory is present for GenBiosId...
2019-02-28 04:12:42 +01:00
set BUILD_PATH = Build\%PLATFORM_NAME% \%TARGET% _%TOOL_CHAIN_TAG%
2015-01-12 10:37:20 +01:00
echo Modifing Conf files for this build...
: : Remove lines with these tags from target.txt
2019-02-28 04:12:42 +01:00
findstr /V " TARGET TARGET_ARCH TOOL_CHAIN_TAG BUILD_RULE_CONF ACTIVE_PLATFORM MAX_CONCURRENT_THREAD_NUMBER " Conf\target.txt > Conf\target.txt.tmp
2015-01-12 10:37:20 +01:00
2019-02-28 04:12:42 +01:00
echo TARGET = %TARGET% >> Conf\target.txt.tmp
2015-01-12 10:37:20 +01:00
if " %Arch% " == " IA32 " (
2019-02-28 04:12:42 +01:00
echo TARGET_ARCH = IA32 >> Conf\target.txt.tmp
2015-01-12 10:37:20 +01:00
) else if "%Arch%"=="X64" (
2019-02-28 04:12:42 +01:00
echo TARGET_ARCH = IA32 X64 >> Conf\target.txt.tmp
2015-01-12 10:37:20 +01:00
)
2019-02-28 04:12:42 +01:00
echo TOOL_CHAIN_TAG = %TOOL_CHAIN_TAG% >> Conf\target.txt.tmp
echo BUILD_RULE_CONF = Conf/build_rule.txt >> Conf\target.txt.tmp
2015-01-12 10:37:20 +01:00
if %Source% == 0 (
2019-02-28 04:12:42 +01:00
echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE% /PlatformPkg%Arch% .dsc >> Conf\target.txt.tmp
2015-01-12 10:37:20 +01:00
) else (
2019-02-28 04:12:42 +01:00
echo ACTIVE_PLATFORM = %PLATFORM_PACKAGE% /PlatformPkg%Arch% Source.dsc >> Conf\target.txt.tmp
2015-01-12 10:37:20 +01:00
)
2019-02-28 04:12:42 +01:00
echo MAX_CONCURRENT_THREAD_NUMBER = %build_threads% >> Conf\target.txt.tmp
2015-01-12 10:37:20 +01:00
2019-02-28 04:12:42 +01:00
move /Y Conf\target.txt.tmp Conf\target.txt > nul
2015-01-12 10:37:20 +01:00
: :**********************************************************************
: : Build BIOS
: :**********************************************************************
echo Creating BiosId...
pushd %PLATFORM_PACKAGE%
2019-02-28 04:12:42 +01:00
if not exist %WORKSPACE% \%BUILD_PATH% \IA32 mkdir %WORKSPACE% \%BUILD_PATH% \IA32
GenBiosId.exe -i %CORE_PATH% \Conf\BiosId.env -o %WORKSPACE% \%BUILD_PATH% \IA32\BiosId.bin -ob %CORE_PATH% \Conf\BiosId.bat
2015-01-12 10:37:20 +01:00
if " %Arch% " == " X64 " (
2019-02-28 04:12:42 +01:00
if not exist %WORKSPACE% \%BUILD_PATH% \X64 mkdir %WORKSPACE% \%BUILD_PATH% \X64
GenBiosId.exe -i %CORE_PATH% \Conf\BiosId.env -o %WORKSPACE% \%BUILD_PATH% \X64\BiosId.bin -ob %CORE_PATH% \Conf\BiosId.bat
2015-01-12 10:37:20 +01:00
)
popd
if %ERRORLEVEL% NEQ 0 goto BldFail
echo .
echo Invoking EDK2 build...
2016-11-29 09:51:26 +01:00
call build %Build_Flags%
2015-01-12 10:37:20 +01:00
if %ERRORLEVEL% NEQ 0 goto BldFail
: :**********************************************************************
: : Post Build processing and cleanup
: :**********************************************************************
echo Running fce...
pushd %PLATFORM_PACKAGE%
: : Extract Hii data from build and store in HiiDefaultData.txt
2019-02-28 04:12:42 +01:00
fce read -i %WORKSPACE% \%BUILD_PATH% \FV\Vlv.fd > %WORKSPACE% \%BUILD_PATH% \FV\HiiDefaultData.txt
2015-01-12 10:37:20 +01:00
2015-06-11 04:50:20 +02:00
: : save changes to VlvXXX.fd
2019-02-28 04:12:42 +01:00
fce update -i %WORKSPACE% \%BUILD_PATH% \FV\Vlv.fd -s %WORKSPACE% \%BUILD_PATH% \FV\HiiDefaultData.txt -o %WORKSPACE% \%BUILD_PATH% \FV\Vlv%Arch% .fd
2015-01-12 10:37:20 +01:00
popd
if %ERRORLEVEL% NEQ 0 goto BldFail
: :echo FD successfully updated with default Hii values.
: : Set the Board_Id, Build_Type, Version_Major, and Version_Minor environment variables
2019-02-28 04:12:42 +01:00
find /v " # " Conf\BiosId.env > ver_strings
2015-01-12 10:37:20 +01:00
for /f " tokens=1,3 " %% i in ( ver_strings) do set %% i = %% j
del /f/q ver_strings > nul
set BIOS_Name = %BOARD_ID% _%Arch% _%BUILD_TYPE% _%VERSION_MAJOR% _%VERSION_MINOR% .ROM
2019-02-28 04:12:42 +01:00
copy /y/b %WORKSPACE% \%BUILD_PATH% \FV\Vlv%Arch% .fd %PLATFORM_PATH% \%BIOS_Name% > nul
copy /y/b %WORKSPACE% \%BUILD_PATH% \FV\Vlv%Arch% .fd %WORKSPACE% \%BUILD_PATH% \FV\Vlv.ROM > nul
2015-01-12 10:37:20 +01:00
echo .
echo Build location: %BUILD_PATH%
echo BIOS ROM Created: %BIOS_Name%
echo .
echo -------------------- The EDKII BIOS build has successfully completed. --------------------
echo .
2016-09-21 05:53:47 +02:00
@ REM build capsule here
2019-02-28 04:12:42 +01:00
@ REMif " %openssl_path% " == " " (
@ REM echo -- Error: OPENSSL_PATH not set. Capule and Recovery images not generated.
@ REM set exitCode=1
@ REM goto Exit
@ REM
@ REM echo > %BUILD_PATH%\FV\SYSTEMFIRMWAREUPDATECARGO.Fv
@ REM build -p %PLATFORM_PACKAGE%\PlatformCapsule.dsc
2016-09-21 05:53:47 +02:00
2015-01-12 10:37:20 +01:00
goto Exit
: Usage
echo .
echo ***************************************************************************
echo Build BIOS rom for VLV platforms.
echo .
echo Usage: bld_vlv.bat [options] PlatformType [Build Target]
echo .
echo /c CleanAll before building
2016-11-29 20:28:07 +01:00
echo /l Generate build log file
echo /y Generate build report file
2016-11-29 21:01:44 +01:00
echo /m Enable multi-processor build
2015-01-12 10:37:20 +01:00
echo /IA32 Set Arch to IA32 (default: X64)
echo /X64 Set Arch to X64 (default: X64)
echo .
echo Platform Types: MNW2
echo Build Targets: Debug, Release (default: Debug)
echo .
echo Examples:
echo bld_vlv.bat MNW2 : X64 Debug build for MinnowMax
echo bld_vlv.bat /IA32 MNW2 release : IA32 Release build for MinnowMax
echo .
echo ***************************************************************************
set exitCode = 1
goto Exit
: BldFail
set exitCode = 1
echo -- Error: EDKII BIOS Build has failed!
echo See EDK2.log for more details
: Exit
echo %date% %time%
exit /b %exitCode%
EndLocal