DuetPkg: Add POSTBUILD in DSC files to run post-build automatically
[mirror_edk2.git] / DuetPkg / PostBuild.bat
1 @echo off
2 @REM ## @file
3 @REM #
4 @REM # Post build script that will be automatically run after build.
5 @REM #
6 @REM # Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
7 @REM #
8 @REM # This program and the accompanying materials
9 @REM # are licensed and made available under the terms and conditions of the BSD License
10 @REM # which accompanies this distribution. The full text of the license may be found at
11 @REM # http://opensource.org/licenses/bsd-license.php
12 @REM # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 @REM # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 @REM #
15 @REM #
16 @REM ##
17
18 set BASETOOLS_DIR=%EDK_TOOLS_BIN%
19 set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin
20
21 :SetDefault
22 set TARGET_ARCH=
23 set TARGET=
24 set TOOL_CHAIN_TAG=
25
26 :ParseParamsLoop
27 if "%1"=="" goto EndPParseParamsLoop
28 if /I "%1"=="-p" goto ParseParamsLoopNext
29 if /I "%1"=="-a" set TARGET_ARCH=%2& goto ParseParamsLoopNext
30 if /I "%1"=="-b" set TARGET=%2& goto ParseParamsLoopNext
31 if /I "%1"=="-t" set TOOL_CHAIN_TAG=%2& goto ParseParamsLoopNext
32 if /I "%1"=="-h" goto Help
33
34 :ParseParamsLoopNext
35 shift
36 shift
37 goto ParseParamsLoop
38
39 :EndPParseParamsLoop
40 if "%TARGET_ARCH%"=="" goto Help
41 if "%TARGET%"=="" goto Help
42 if "%TOOL_CHAIN_TAG%"=="" goto Help
43
44 set PROCESSOR=%TARGET_ARCH%
45 set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
46
47 @REM Store environment variables used by CreateBootDisk.bat
48 echo set TARGET=%TARGET%> %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat
49 echo set TOOL_CHAIN_TAG=%TOOL_CHAIN_TAG%>> %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat
50
51 echo Compressing DUETEFIMainFv.FV ...
52 %BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DUETEFIMAINFV.z %BUILD_DIR%\FV\DUETEFIMAINFV.Fv
53
54 echo Compressing DxeMain.efi ...
55 %BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\%PROCESSOR%\DxeCore.efi
56
57 echo Compressing DxeIpl.efi ...
58 %BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\%PROCESSOR%\DxeIpl.efi
59
60 echo Generate Loader Image ...
61 if "%PROCESSOR%"=="IA32" goto GENERATE_IMAGE_IA32
62 if "%PROCESSOR%"=="X64" goto GENERATE_IMAGE_X64
63
64 :GENERATE_IMAGE_IA32
65 %BASETOOLS_DIR%\EfiLdrImage.exe -o %BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
66 copy /b %BOOTSECTOR_BIN_DIR%\Start.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr
67 copy /b %BOOTSECTOR_BIN_DIR%\Start16.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr16
68 copy /b %BOOTSECTOR_BIN_DIR%\Start32.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr20
69 goto end
70
71 :GENERATE_IMAGE_X64
72 %BASETOOLS_DIR%\EfiLdrImage.exe -o %BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
73 copy /b %BOOTSECTOR_BIN_DIR%\Start64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\EfildrPure
74 %BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\EfildrPure -o %BUILD_DIR%\FV\Efildr
75 copy /b %BOOTSECTOR_BIN_DIR%\St16_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\Efildr16Pure
76 %BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr16Pure -o %BUILD_DIR%\FV\Efildr16
77 copy /b %BOOTSECTOR_BIN_DIR%\St32_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\Efildr20Pure
78 %BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr20Pure -o %BUILD_DIR%\FV\Efildr20
79 goto end
80
81 :Help
82 echo Usage: This script will be run automatically after build.
83 :end