klu2 | 71bd6db | 2009-03-02 12:12:46 +0000 | [diff] [blame] | 1 | #!/bin/sh |
klu2 | ab9cb4b | 2010-03-18 02:36:52 +0000 | [diff] [blame] | 2 | |
| 3 | ## @file |
| 4 | # |
| 5 | # Currently, Build system does not provide post build mechanism for module |
| 6 | # and platform building, so just use a sh file to do post build commands. |
| 7 | # Originally, following post building command is for EfiLoader module. |
| 8 | # |
hhtian | b1f700a | 2010-04-28 12:39:50 +0000 | [diff] [blame] | 9 | # Copyright (c) 2010, Intel Corporation. All rights reserved.<BR> |
klu2 | ab9cb4b | 2010-03-18 02:36:52 +0000 | [diff] [blame] | 10 | # |
| 11 | # This program and the accompanying materials |
| 12 | # are licensed and made available under the terms and conditions of the BSD License |
| 13 | # which accompanies this distribution. The full text of the license may be found at |
| 14 | # http://opensource.org/licenses/bsd-license.php |
| 15 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. |
| 17 | # |
| 18 | ## |
klu2 | 71bd6db | 2009-03-02 12:12:46 +0000 | [diff] [blame] | 19 | |
jljusten | 9046a2f | 2010-10-16 18:50:33 +0000 | [diff] [blame] | 20 | if [ -z "$EDK_TOOLS_PATH" ] |
| 21 | then |
klu2 | df6434f | 2009-09-17 02:16:30 +0000 | [diff] [blame] | 22 | export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin |
jljusten | 9046a2f | 2010-10-16 18:50:33 +0000 | [diff] [blame] | 23 | else |
| 24 | export BASETOOLS_DIR=$EDK_TOOLS_PATH/Source/C/bin |
| 25 | fi |
| 26 | |
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 27 | export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 28 | export PROCESSOR="" |
| 29 | if [ \ |
| 30 | -z "$1" -o \ |
| 31 | "$1" = "-?" -o \ |
| 32 | "$1" = "-h" -o \ |
| 33 | "$1" = "--help" \ |
| 34 | ] |
| 35 | then |
| 36 | echo Error! Please specific the architecture. |
klu2 | 63c89e0 | 2010-06-10 08:54:18 +0000 | [diff] [blame] | 37 | echo Usage: "./PostBuild.sh [IA32|X64] [UNIXGCC|GCC44]" |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 38 | fi |
| 39 | |
klu2 | 71bd6db | 2009-03-02 12:12:46 +0000 | [diff] [blame] | 40 | case "$1" in |
| 41 | IA32) |
| 42 | export PROCESSOR=IA32 |
| 43 | ;; |
| 44 | X64) |
| 45 | export PROCESSOR=X64 |
| 46 | ;; |
| 47 | *) |
| 48 | echo Invalid Architecture string, should be only IA32 or X64 |
klu2 | f8b30ae | 2009-04-16 02:36:20 +0000 | [diff] [blame] | 49 | return 1 |
klu2 | 71bd6db | 2009-03-02 12:12:46 +0000 | [diff] [blame] | 50 | esac |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 51 | |
klu2 | 63c89e0 | 2010-06-10 08:54:18 +0000 | [diff] [blame] | 52 | case "$2" in |
| 53 | UNIXGCC) |
| 54 | export TOOLTAG=UNIXGCC |
| 55 | ;; |
| 56 | GCC44) |
| 57 | export TOOLTAG=GCC44 |
| 58 | ;; |
| 59 | *) |
| 60 | echo Invalid tool tag, should be only UNIXGCC or GCC44 |
| 61 | return 1 |
| 62 | esac |
| 63 | |
| 64 | export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLTAG |
klu2 | ab9cb4b | 2010-03-18 02:36:52 +0000 | [diff] [blame] | 65 | |
| 66 | |
klu2 | 71bd6db | 2009-03-02 12:12:46 +0000 | [diff] [blame] | 67 | # |
| 68 | # Boot sector module could only be built under IA32 tool chain |
| 69 | # |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 70 | |
| 71 | echo Compressing DUETEFIMainFv.FV ... |
gikidy | 11d909a | 2009-05-06 09:03:11 +0000 | [diff] [blame] | 72 | $BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DUETEFIMAINFV.z $BUILD_DIR/FV/DUETEFIMAINFV.Fv |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 73 | |
| 74 | echo Compressing DxeMain.efi ... |
gikidy | 11d909a | 2009-05-06 09:03:11 +0000 | [diff] [blame] | 75 | $BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/$PROCESSOR/DxeCore.efi |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 76 | |
| 77 | echo Compressing DxeIpl.efi ... |
gikidy | 11d909a | 2009-05-06 09:03:11 +0000 | [diff] [blame] | 78 | $BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/$PROCESSOR/DxeIpl.efi |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 79 | |
| 80 | echo Generate Loader Image ... |
| 81 | |
| 82 | if [ $PROCESSOR = IA32 ] |
| 83 | then |
klu2 | 63c89e0 | 2010-06-10 08:54:18 +0000 | [diff] [blame] | 84 | $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 85 | $BASETOOLS_DIR/EfiLdrImage -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 |
klu2 | 63c89e0 | 2010-06-10 08:54:18 +0000 | [diff] [blame] | 86 | cat $BOOTSECTOR_BIN_DIR/Start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr |
klu2 | fe9591c | 2009-03-16 04:59:21 +0000 | [diff] [blame] | 87 | # |
| 88 | # It is safe to use "bcat" to cat following binary file, if bcat command is avaiable for your system |
| 89 | # |
klu2 | df6434f | 2009-09-17 02:16:30 +0000 | [diff] [blame] | 90 | #bcat -o $BUILD_DIR/FV/Efildr.bcat $BOOTSECTOR_BIN_DIR/start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 |
klu2 | 63c89e0 | 2010-06-10 08:54:18 +0000 | [diff] [blame] | 91 | cat $BOOTSECTOR_BIN_DIR/Start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr16 |
klu2 | df6434f | 2009-09-17 02:16:30 +0000 | [diff] [blame] | 92 | #bcat -o $BUILD_DIR/FV/Efildr16.bcat $BOOTSECTOR_BIN_DIR/start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 |
klu2 | 63c89e0 | 2010-06-10 08:54:18 +0000 | [diff] [blame] | 93 | cat $BOOTSECTOR_BIN_DIR/Start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr20 |
klu2 | df6434f | 2009-09-17 02:16:30 +0000 | [diff] [blame] | 94 | #bcat -o $BUILD_DIR/FV/Efildr20.bcat $BOOTSECTOR_BIN_DIR/start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 95 | echo Done! |
| 96 | fi |
| 97 | |
| 98 | if [ $PROCESSOR = X64 ] |
| 99 | then |
klu2 | 63c89e0 | 2010-06-10 08:54:18 +0000 | [diff] [blame] | 100 | $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 101 | $BASETOOLS_DIR/EfiLdrImage -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 |
klu2 | 9e8c32c | 2009-07-08 07:25:02 +0000 | [diff] [blame] | 102 | cat $BOOTSECTOR_BIN_DIR/Start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/EfildrPure |
klu2 | df6434f | 2009-09-17 02:16:30 +0000 | [diff] [blame] | 103 | #bcat -o $BUILD_DIR/FV/EfildrPure $BOOTSECTOR_BIN_DIR/start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 104 | $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/EfildrPure -o $BUILD_DIR/FV/Efildr |
klu2 | 9e8c32c | 2009-07-08 07:25:02 +0000 | [diff] [blame] | 105 | cat $BOOTSECTOR_BIN_DIR/St16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr16Pure |
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 106 | #bcat -o $BUILD_DIR/FV/Efildr16Pure $BOOTSECTOR_BIN_DIR/st16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 107 | $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr16Pure -o $BUILD_DIR/FV/Efildr16 |
klu2 | 9e8c32c | 2009-07-08 07:25:02 +0000 | [diff] [blame] | 108 | cat $BOOTSECTOR_BIN_DIR/St32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr20Pure |
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 109 | #bcat -o $BUILD_DIR/FV/Efildr20Pure $BOOTSECTOR_BIN_DIR/st32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 |
gikidy | f89afdd | 2009-03-02 08:37:23 +0000 | [diff] [blame] | 110 | $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr20Pure -o $BUILD_DIR/FV/Efildr20 |
| 111 | |
| 112 | echo Done! |
| 113 | fi |
| 114 | |
klu2 | f8b30ae | 2009-04-16 02:36:20 +0000 | [diff] [blame] | 115 | |